Note:
 
Server operating system: CentOS 6.x
 
Server IP address: 192.168.21.134
 
Purpose:
 
1. Install and configure the SVN service on the server;
 
2. Configure the SVN service to support both http and svnserve independent servers of Apache;
 
3. The http and svnserve independent servers of Apache use the same access account.
 
Specific operations:
 
1. Disable SELINUX
 
Vi/etc/selinux/config
 
# SELINUX = enforcing # Comment out
 
# SELINUXTYPE = targeted # Comment out
 
SELINUX = disabled # Add
 
: Wq! # Save and exit
 
Setenforce 0 # Make the configuration take effect immediately
 
2. Enable the firewall Port
 
System O & M www.111cn.net reminder: Original System O & M content © copyright © reprinted, please indicate the source and original link
 
Apache-based http mode. The default port is 80.
 
Standalone server mode based on svnserve. The default port is 3690.
 
Vi/etc/sysconfig/iptables # Edit the firewall configuration file
 
# Firewall configuration written by system-config-firewall
 
# Manual customization of this file is not recommended.
 
* Filter
 
: Input accept [0: 0]
 
: Forward accept [0: 0]
 
: Output accept [0: 0]
 
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
 
-A input-p icmp-j ACCEPT
 
-A input-I lo-j ACCEPT
 
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
 
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
 
-A input-m state -- state NEW-m tcp-p tcp -- dport 3690-j ACCEPT
 
-A input-j REJECT -- reject-with icmp-host-prohibited
 
-A forward-j REJECT -- reject-with icmp-host-prohibited
 
COMMIT
 
: Wq! # Save and exit
 
Service iptables restart # restart the firewall to make the configuration take effect.
 
3. Install Apache
 
Yum install httpd apr-util httpd-devel # install Apache
 
Yum install mod_dav_svn mod_auth_mysql # install the Support Module for Apache-based http mode access
 
Chkconfig httpd on # set startup
 
Service httpd start # start Apache
 
Httpd-version # View Apache version information
 
Cd/etc/httpd/modules/
 
# Check whether the mod_dav_svn.so and mod_authz_svn.so modules exist. If so, mod_dav_svn is successfully installed!
 
# The mod_auth_mysql module uses the database to store account information. This tutorial does not involve any installation!
 
Note: If an error is prompted after Apache is started:
 
Httpd: cocould not reliably determine the server's fully qualif domain name, using: 1 for ServerName
 
Solution:
 
Vi/etc/httpd/conf/httpd. conf # Edit
 
ServerName www.example.com: 80 # Remove the preceding comment
 
: Wq! # Save and exit
 
4. Install SVN
 
Yum install subversion # Use The yum command for online installation
 
Svnserve -- version # View svn version information
 
V. Configure SVN
 
1. Create an svn version Library
 
Mkdir-p/home/svn # Create an svn version inventory Directory
 
Cd/home/svn # enter the Directory
 
Svnadmin create/home/svn/project1 # create the svn version Library project1
 
Svnadmin create/home/svn/project2 # create the svn version Library project2
 
Svnadmin create/home/svn/project3 # create the svn version Library project3
 
2. Set the configuration file
 
Mkdir-p/home/svn/conf # Create a configuration file directory
 
Cp/home/svn/project1/conf/passwd/home/svn/conf/passwd # Copy the account and password configuration file Template
 
Cp/home/svn/project1/conf/authz/home/svn/conf/authz # Copy the directory permission configuration file Template
 
Cp/home/svn/project1/conf/passwd/home/svn/conf/svnserve. conf # Copy the global configuration file Template
 
Vi/home/svn/conf/passwd # edit and add the following code
 
[Users]
 
# Harry = harryssecret
 
# Sally = sallyssecret
 
Osyunwei= 123456
 
Ossyunwei1 = 123456
 
Ossyunwei2 = 123456
 
Ossyunwei3 = 123456
 
: Wq! # Save and exit
 
Vi/home/svn/conf/authz # edit and add the following code
 
[Groups]
 
Admin = osyunwei
 
Project1 = osyunwei1
 
Project2 = osyunwei2
 
Project3 = osyunwei3
 
[/]
 
@ Admin = rw
 
* =
 
[Project1:/]
 
@ Admin = rw
 
@ Project1 = rw
 
* =
 
[Project2:/]
 
@ Admin = rw
 
@ Project2 = rw
 
* =
 
[Project3:/]
 
@ Admin = rw
 
@ Project3 = rw
 
* =
 
: Wq! # Save and exit
 
Vi/home/svn/conf/svnserve. conf # configure the global file and add the following code at the end
 
[General]
 
Anon-access = none # disable anonymous access and set it to none. The default value is read. Parameters include read, write, and none.
 
Auth-access = write # authorize the user to write
 
Password-db =/home/svn/conf/passwd # path of the user account password file, which can be an absolute path
 
Authz-db =/home/svn/conf/authz # path of the access control permission file, which can be an absolute path
 
Realm = svn # The authentication life of each SVN project is displayed in the authentication prompt. We recommend that you write the project name.
 
: Wq! # Save and exit
 
3. Start SVN
 
Svnserve-d-r/home/svn -- config-file/home/svn/conf/svnserve. conf -- listen-port 3690
 
# -- Config-file followed by the global configuration parameter file
 
Ps-ef | grep svn | grep-v grep # view the process
 
Netstat-ln | grep 3690 # check port
 
Killall svnserve # Disable svn
 
4. Set svn service startup
 
System O & M www.111cn.net reminder: Original System O & M content © copyright © reprinted, please indicate the source and original link
 
Vi/etc/init. d/svn # edit and add the following code
 
#! /Bin/sh
 
# Chkconfig: 2345 85
 
# Processname: svn
 
Svn_bin =/usr/local/svn/bin
 
Svn_ports = 3690
 
Svn_home =/home/svn
 
Svn_config =/home/svn/conf/svnserve. conf
 
If [! -F "$ svn_bin/svnserve"]
 
Then
 
Echo "svnserver startup: cannot start"
 
Exit
 
Fi
 
Case "$1" in
 
Start)
 
Echo "Starting svnserve ..."
 
$ Svn_bin/svnserve-d-r $ svn_home -- config-file $ svn_config -- listen-port $ svn_port
 
Echo "Successfully! "
 
;;
 
Stop)
 
Echo "Stoping svnserve ..."
 
Killall svnserve
 
Echo "Successfully! "
 
;;
 
Restart)
 
$0 stop
 
$0 start
 
;;
 
*)
 
Echo "Usage: svn {start | stop | restart }"
 
Exit 1
 
Esac
 
: Wq! # Save and exit
 
Chmod + x/etc/init. d/svn # Add execution permission
 
Chkconfig svn on # automatic startup
 
Service svn start # start
 
6. Configure svn to support http access
 
1. Create an account and password authentication file
 
Htpasswd-cm/home/svn/conf/http_passwd osyunwei
 
Htpasswd-m/home/svn/conf/http_passwd osyunwei1
 
Htpasswd-m/home/svn/conf/http_passwd osyunwei2
 
Htpasswd-m/home/svn/conf/http_passwd osyunwei3
 
Enter the password twice as prompted.
 
Note:
 
The passwd file under the/home/svn/conf/directory is the authentication file used by the svnserve independent server. The password is not encrypted and is displayed in plaintext.
 
The http_passwd file under the/home/svn/conf/directory is the authentication file used by Apache in http mode, and the password is encrypted with MD5.
 
In the passwd and http_passwd files, the account and password must be set to the same.
 
2. Set the Apache configuration file
 
Vi/etc/httpd/conf. d/subversion. conf # edit and add the following code at the end
 
 
DAV svn
 
# SVNPath/home/svn
 
SVNParentPath/home/svn
 
# Limit write permission to list of valid users.
 
#
 
# Require SSL connection for password protection.
 
# SSLRequireSSL
 
#
 
AuthType Basic
 
AuthName "Authorization SVN"
 
AuthzSVNAccessFile/home/svn/conf/authz
 
AuthUserFile/home/svn/conf/http_passwd
 
Require valid-user
 
#
 
 
: Wq! # Save and exit
 
3. Set directory permissions
 
Chown apache: apache/home/svn-R # set the svn Directory owner to the Apache service running account apache
 
4. Restart the Apache service.
 
Service httpd restart # restart
 
VII. Test svn
 
Install the svn client TortoiseSVN in Windows.
 
TortoiseSVN download address: http://tortoisesvn.net/downloads.html
 
After the installation is complete, right-click the desktop and choose TortoiseSVN-version library browser.
 
 
URL input: svn: // 192.168.21.134/project1
 
User Name: osyunwei1
 
Password 123456
 
Check: save authentication
 
OK
 
 
You can go to the project T1 version Library Directory, right-click it, and choose Create folder and other operations.
 
 
URL input: http: // 192.168.21.134/svn/project1
 
The user name and password are the same as above. You can go to the Project 1 version Library Directory, right-click it, and choose Create folder and other operations.
 
 
Project1 access:
 
Svn: // 192.168.21.134/project1
 
Http: // 192.168.21.134/svn/project1
 
User Name: osyunwei1
 
Password 123456
 
Project2 access:
 
Svn: // 192.168.21.134/project2
 
Http: // 192.168.21.134/svn/project2
 
Username: osyunwei2
 
Password 123456
 
Project3 access:
 
Svn: // 192.168.21.134/project3 # svnserve independent server mode
 
Http: // 192.168.21.134/svn/project3 # http mode of Apache
 
Username: osyunwei3
 
Password 123456
 
Additional reading:
 
1. Parameters of the Apache htpasswd command
 
-C. Create an encrypted file
 
-N: If the encrypted file is not updated, only the user name and password encrypted by the apache htpasswd command are displayed on the screen.
 
-M by default, the apache htpassswd command uses the MD5 algorithm to encrypt the password.
 
-D the apache htpassswd command uses the CRYPT algorithm to encrypt the password.
 
-P apache htpassswd command does not encrypt the password, that is, the plaintext password
 
-S apache htpassswd command uses SHA algorithm to encrypt the password
 
-B enters the user name and password in the apache htpassswd command line instead of entering the password as prompted.
 
-D. Delete the specified user.
 
2. Differences between SVNPath and SVNParentPath:
 
SVNParentPath: supports multiple SVN version libraries with the same parent directory.
 
SVNPath: only the SVN version library of the main directory is supported. If a new project is created under the main directory, no access is allowed.