[sheldon@localhost Desktop]$ su
Password:
[root@localhost Desktop]# vi /etc/passwd
[root@localhost Desktop]# service httpd start
Starting httpd: [ OK ]
[root@localhost Desktop]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: May 13 2013 22:08:57
[root@localhost Desktop]# yum install -y subversion mod_dav_svn
[root@localhost Desktop]# vi /etc/httpd/conf.d/subversion.conf
[root@localhost Desktop]# htpasswd -cm /etc/svn-auth-users mu
New password:
Re-type new password:
Adding password for user mu
[root@localhost Desktop]# mkdir /home/svn
[root@localhost Desktop]# cd /home/svn
[root@localhost svn]# svnadmin create helpdesk
[root@localhost svn]# chown -R apache.apache helpdesk
[root@localhost svn]# ls -al
total 12
drwxr-xr-x. 3 root root 4096 Jun 14 10:18 .
drwxr-xr-x. 4 root root 4096 Jun 14 10:17 ..
drwxr-xr-x. 6 apache apache 4096 Jun 14 10:18 helpdesk
[root@localhost svn]# vi /etc/sysconfig/iptables
[root@localhost svn]# /etc/init.d/iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@localhost svn]# chkconfig httpd on
[root@localhost svn]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost svn]# pwd
/home/svn
[root@localhost svn]# cd /home/svn/helpdesk
[root@localhost helpdesk]# ls -al
total 32
drwxr-xr-x. 6 apache apache 4096 Jun 14 10:18 .
drwxr-xr-x. 3 root root 4096 Jun 14 10:18 ..
drwxr-xr-x. 2 apache apache 4096 Jun 14 10:18 conf
drwxr-sr-x. 6 apache apache 4096 Jun 14 10:18 db
-r--r--r--. 1 apache apache 2 Jun 14 10:18 format
drwxr-xr-x. 2 apache apache 4096 Jun 14 10:18 hooks
drwxr-xr-x. 2 apache apache 4096 Jun 14 10:18 locks
-rw-r--r--. 1 apache apache 229 Jun 14 10:18 README.txt
[root@localhost /]# svnserve -d -r /home/svn/helpdesk
[root@localhost /]# cd /home/svn/helpdesk/conf
[root@localhost conf]# ls -al
total 20
drwxr-xr-x. 2 apache apache 4096 Jun 14 10:18 .
drwxr-xr-x. 6 apache apache 4096 Jun 14 10:18 ..
-rw-r--r--. 1 apache apache 1080 Jun 14 10:18 authz
-rw-r--r--. 1 apache apache 309 Jun 14 10:18 passwd
-rw-r--r--. 1 apache apache 2279 Jun 14 10:18 svnserve.conf
[root@localhost conf]# vi passwd
[root@localhost conf]# vi authz
[root@localhost conf]# vi svnserve.conf
[root@localhost conf]# killall svnserve
[root@localhost conf]# svnserve -d -r /home/svn/helpdesk
[root@localhost conf]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost conf]# cd /home
[root@localhost home]# chown -R apache:apache svn
[root@localhost home]# ls -al
total 16
drwxr-xr-x. 4 root root 4096 Jun 14 10:17 .
dr-xr-xr-x. 21 root root 4096 Jun 14 09:33 ..
drwx------. 27 sheldon sheldon 4096 Jun 14 10:27 sheldon
drwxr-xr-x. 3 apache apache 4096 Jun 14 10:18 svn
[root@localhost home]# cd svn
[root@localhost svn]# vi /etc/selinux/config
[root@localhost svn]# getenforce
Enforcing
[root@localhost svn]# setenforce 0
[root@localhost svn]# cd ~
[root@localhost ~]# ls
anaconda-ks.cfg install.log install.log.syslog
[root@localhost ~]# mkdir svn-templates
[root@localhost ~]# cd svn-templates/
[root@localhost svn-templates]# mkdir softwares
[root@localhost svn-templates]# mkdir files
[root@localhost svn-templates]# mkdir trunk
[root@localhost svn-templates]# cd ~
[root@localhost ~]# chown -R apache:apache svn-templates
[root@localhost ~]# ls -al
total 100
dr-xr-x---. 3 root root 4096 Jun 14 11:05 .
dr-xr-xr-x. 21 root root 4096 Jun 14 09:33 ..
-rw-------. 1 root root 2694 Jun 4 07:38 anaconda-ks.cfg
-rw-------. 1 root root 393 Jun 14 10:26 .bash_history
-rw-r--r--. 1 root root 18 May 20 2009 .bash_logout
-rw-r--r--. 1 root root 176 May 20 2009 .bash_profile
-rw-r--r--. 1 root root 176 Sep 22 2004 .bashrc
-rw-r--r--. 1 root root 100 Sep 22 2004 .cshrc
-rw-r--r--. 1 root root 39343 Jun 4 07:38 install.log
-rw-r--r--. 1 root root 9154 Jun 4 07:36 install.log.syslog
drwxr-xr-x. 5 apache apache 4096 Jun 14 11:06 svn-templates
-rw-r--r--. 1 root root 129 Dec 3 2004 .tcshrc
-rw-------. 1 root root 66 Jun 14 10:06 .xauthWzU62m
[root@localhost ~]# cd svn-templates
[root@localhost svn-templates]# ls -al
total 20
drwxr-xr-x. 5 apache apache 4096 Jun 14 11:06 .
dr-xr-x---. 3 root root 4096 Jun 14 11:05 ..
drwxr-xr-x. 2 apache apache 4096 Jun 14 11:06 files
drwxr-xr-x. 2 apache apache 4096 Jun 14 11:06 softwares
drwxr-xr-x. 2 apache apache 4096 Jun 14 11:06 trunk
[root@localhost svn-templates]# cd ~
[root@localhost ~]# svn import -m 'Initial import' svn-templates/ http://192.168.197.130/svn/helpdesk/
Authentication realm: <http://192.168.197.130:80> Subversion repositories
Password for 'root': [Enter]
Authentication realm: <http://192.168.197.130:80> Subversion repositories
Username: mu[Enter]
Password for 'mu': [入力+Enter]
Adding svn-templates/files
Adding svn-templates/trunk
Adding svn-templates/softwares
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<http://192.168.197.130:80> Subversion repositories
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
Committed revision 1.
[root@localhost ~]# mkdir /var/www/html/helpdesk
[root@localhost ~]# cd /var/www/html
[root@localhost html]# chown -R apache:apache helpdesk
[root@localhost html]# su apache
bash-4.1$ svn checkout http://192.168.197.130/svn/helpdesk/trunk/ /var/www/html/helpdesk/
Authentication realm: <http://192.168.197.130:80> Subversion repositories
Password for 'apache': [Enter]
Authentication realm: <http://192.168.197.130:80> Subversion repositories
Username: mu
Password for 'mu': [pass+Enter]
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<http://192.168.197.130:80> Subversion repositories
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/var/www/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
A /var/www/html/helpdesk/Hello.txt
Checked out revision 2.
bash-4.1$ svn update /var/www/html/helpdesk --username mu --password neo12345
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<http://192.168.197.130:80> Subversion repositories
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/var/www/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
At revision 2.
bash-4.1$ su
Password:
[root@localhost svn]# cd /home/svn/helpdesk/hooks
[root@localhost hooks]# ls -al
total 44
drwxr-xr-x. 2 apache apache 4096 Jun 14 10:18 .
drwxr-xr-x. 7 apache apache 4096 Jun 14 11:09 ..
-rw-r--r--. 1 apache apache 1977 Jun 14 10:18 post-commit.tmpl
-rw-r--r--. 1 apache apache 1638 Jun 14 10:18 post-lock.tmpl
-rw-r--r--. 1 apache apache 2289 Jun 14 10:18 post-revprop-change.tmpl
-rw-r--r--. 1 apache apache 1567 Jun 14 10:18 post-unlock.tmpl
-rw-r--r--. 1 apache apache 3426 Jun 14 10:18 pre-commit.tmpl
-rw-r--r--. 1 apache apache 2410 Jun 14 10:18 pre-lock.tmpl
-rw-r--r--. 1 apache apache 2786 Jun 14 10:18 pre-revprop-change.tmpl
-rw-r--r--. 1 apache apache 2100 Jun 14 10:18 pre-unlock.tmpl
-rw-r--r--. 1 apache apache 2780 Jun 14 10:18 start-commit.tmpl
[root@localhost hooks]# cp post-commit.tmpl post-commit
[root@localhost hooks]# vi post-commit
[root@localhost hooks]# chown -R apache:apache post-commit
[root@localhost hooks]# chmod 777 post-commit
[root@localhost hooks]# ls -al
total 48
drwxr-xr-x. 2 apache apache 4096 Jun 14 11:36 .
drwxr-xr-x. 7 apache apache 4096 Jun 14 11:09 ..
-rwxrwxrwx. 1 apache apache 352 Jun 14 11:36 post-commit
-rw-r--r--. 1 apache apache 1977 Jun 14 10:18 post-commit.tmpl
-rw-r--r--. 1 apache apache 1638 Jun 14 10:18 post-lock.tmpl
-rw-r--r--. 1 apache apache 2289 Jun 14 10:18 post-revprop-change.tmpl
-rw-r--r--. 1 apache apache 1567 Jun 14 10:18 post-unlock.tmpl
-rw-r--r--. 1 apache apache 3426 Jun 14 10:18 pre-commit.tmpl
-rw-r--r--. 1 apache apache 2410 Jun 14 10:18 pre-lock.tmpl
-rw-r--r--. 1 apache apache 2786 Jun 14 10:18 pre-revprop-change.tmpl
-rw-r--r--. 1 apache apache 2100 Jun 14 10:18 pre-unlock.tmpl
-rw-r--r--. 1 apache apache 2780 Jun 14 10:18 start-commit.tmpl
[root@localhost hooks]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost hooks]#
文件内容
[root@localhost hooks]# pwd
/home/svn/helpdesk/hooks
[root@localhost hooks]# cat post-commit
#!/bin/sh
REPOS="$1"
REV="$2"
SVN=/usr/bin/svn
WEB=/var/www/html/helpdesk
LOG_PATH=/tmp/svn_update.log
echo"\n\n\n##########COMMIT " `date "+%Y-%m-%d %H:%M:%S"`'##################' >> $LOG_PATH
echo `whoami`,$REPOS,$REV>> $LOG_PATH
"$SVN" update--username mu --password neo12345"$WEB" --no-auth-cache >> "$LOG_PATH"
chown -R apache:apache"$WEB"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[root@localhost hooks]# vi /etc/passwd
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxduser:/:/sbin/nologin
vcsa:x:69:69:virtual console memoryowner:/dev:/sbin/nologin
rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LLStack:/var/lib/avahi-autoipd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
pulse:x:498:496:PulseAudio SystemDaemon:/var/run/pulse:/sbin/nologin
haldaemon:x:68:68:HALdaemon:/:/sbin/nologin
saslauth:x:497:76:"Saslauthduser":/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/bin/bash
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
sshd:x:74:74:Privilege-separatedSSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
sheldon:x:500:500:SheldonCooper:/home/sheldon:/bin/bash
[root@localhost hooks]# vi/etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/svn-auth-users
Require valid-user
</Location>
#
# Example configuration to enable HTTP access for adirectory
# containing Subversion repositories,"/var/www/svn". Eachrepository
# must be both:
#
# a)readable and writable by the 'apache' user, and
#
# b)labelled with the 'httpd_sys_content_t' context if using
# SELinux
#
[root@localhost hooks]# cat /etc/sysconfig/iptables
# Firewall configuration written bysystem-config-firewall
# Manual customization of this file is notrecommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -jACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport22 -j ACCEPT
-A INPUT -p udp -m state --state NEW--dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW--dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-withicmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@localhosthooks]#
[root@localhost conf]# cat authz
### This file is an example authorization file forsvnserve.
### Its format is identical to that ofmod_authz_svn authorization
### files.
### As shown below each section definesauthorizations for the path and
### (optional) repository specified by the sectionname.
### The authorizations follow. An authorizationline can refer to:
### - asingle user,
### - agroup of users defined in a special [groups] section,
### - an aliasdefined in a special [aliases] section,
### - allauthenticated users, using the '$authenticated' token,
### - onlyanonymous users, using the '$anonymous' token,
### -anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rulewith '~'. Rules can
### grant read ('r') access, read-write ('rw')access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil,Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
mu=rw
[root@localhostconf]#
[root@localhost conf]# vi passwd
### This file is an example password file forsvnserve.
### Its format is similar to that of svnserve.conf.As shown in the
### example below it contains one section labelled[users].
### The name and password for each user follow, oneaccount per line.
[users]
# harry = harryssecret
# sally = sallyssecret
mu= neo12345
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[root@localhost conf]# vi svnserve.conf
### This file controls the configuration ofthe svnserve daemon, if you
### use it to allow access to thisrepository. (If you only allow
### access through http: and/or file: URLs,then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ formore information.
[general]
### These options control access to therepository for unauthenticated
### and authenticated users. Valid values are "write","read",
### and "none". The sample settings below are the defaults.
anon-access = none
auth-access = write
### The password-db option controls thelocation of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to thedirectory containing
### this configuration file.
### If SASL is enabled (see below), thisfile will NOT be used.
### Uncomment the line below to use thedefault password file.
password-db = passwd
### The authz-db option controls thelocation of the authorization
### rules for path-based accesscontrol. Unless you specify a path
### starting with a /, the file's locationis relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access controlis done.
### Uncomment the line below to use thedefault authorization file.
authz-db = authz
### This option specifies theauthentication realm of the repository.
### If two repositories have the sameauthentication realm, they should
### have the same password database, andvice versa. The default realm
### is repository's uuid.
# realm = My First Repository
realm =/home/svn/helpdesk
[sasl]
### This option specifies whether you wantto use the Cyrus SASL
### library for authentication. Default isfalse.
### This section will be ignored ifsvnserve is not built with Cyrus
### SASL support; to check, run 'svnserve--version' and look for a line
### reading 'Cyrus SASL authentication isavailable.'
# use-sasl = true
### These options specify the desiredstrength of the security layer
### that you want SASL to provide. 0 meansno encryption, 1 means
### integrity-checking only, values largerthan 1 are correlated
### to the effective key length forencryption (e.g. 128 means 128-bit
### encryption). The values below are thedefaults.
# min-encryption = 0
#max-encryption = 256
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[root@localhost conf]# cat /etc/selinux/config
# This file controls the state of SELinux on thesystem.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls -Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost conf]#