Description
Server operating system: CentOS 6.x
Server ip:192.168.21.134
To achieve the purpose:
1, install the Configuration SVN service on the server;
2, configure the SVN service also supports Apache HTTP and svnserve Independent server two modes of access;
3, Apache HTTP and svnserve Independent server two modes of use the same access rights account.
Specific actions:
First, close SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
selinux=disabled #增加
: wq! #保存退出
Setenforce 0 #使配置立即生效
Second, open the firewall port
System Yun-wei www.osyunwei.com warm reminder: System operation of the original content © copyright, reproduced please indicate the source and the original link
Apache based HTTP mode with a default port of 80
Standalone server mode based on Svnserve, default port is 3690
Vi/etc/sysconfig/iptables #编辑防火墙配置文件
# 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! #保存退出
Service iptables restart #最后重启防火墙使配置生效
Third, the installation of Apache
Yum install httpd Apr apr-util httpd-devel #安装Apache
Yum install mod_dav_svn mod_auth_mysql #安装基于Apache的http模式访问的支持模块
Chkconfig httpd on #设置开机启动
Service httpd start #启动Apache
Httpd-version #查看Apache版本信息
cd/etc/httpd/modules/
#查看是否有mod_dav_svn. So and mod_authz_svn.so modules, if any, MOD_DAV_SVN installation success!
#mod_auth_mysql模块是用数据库存储账号信息, this tutorial is not covered and can not be installed!
NOTE: If Apache prompts for an error after startup:
Httpd:httpd:Could not reliably determine the server's fully Qualif domain name using:: 1 for ServerName
Solution:
vi/etc/httpd/conf/httpd.conf #编辑
ServerName www.example.com:80 #去掉前面的注释
: wq! #保存退出
Four, install SVN
Yum Install subversion #使用yum命令在线安装
Svnserve--version #查看svn版本信息
Five, configure SVN
1. Create SVN version Library
Mkdir-p/home/svn #创建svn版本库存放目录
CD/HOME/SVN #进入目录
Svnadmin Create/home/svn/project1 #创建svn版本库project1
Svnadmin create/home/svn/project2 #创建svn版本库project2
Svnadmin create/home/svn/project3 #创建svn版本库project3
2, set the configuration file
Mkdir-p/home/svn/conf #创建配置文件目录
CP/HOME/SVN/PROJECT1/CONF/PASSWD/HOME/SVN/CONF/PASSWD #拷贝账号密码配置文件模板
Cp/home/svn/project1/conf/authz/home/svn/conf/authz #拷贝目录权限配置文件模板
cp/home/svn/project1/conf/passwd/home/svn/conf/svnserve.conf #拷贝全局配置文件模板
VI/HOME/SVN/CONF/PASSWD #编辑, add the following code
[Users]
# Harry = Harryssecret
# sally = Sallyssecret
osyunwei=123456
osyunwei1=123456
osyunwei2=123456
osyunwei3=123456
: wq! #保存退出
Vi/home/svn/conf/authz #编辑, 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! #保存退出
Vi/home/svn/conf/svnserve.conf #配置全局文件, add the following code at the end
[General]
Anon-access=none #禁止匿名访问, set to none. Default to read, parameters: Read,write,none
Auth-access=write #授权用户写权限
PASSWORD-DB=/HOME/SVN/CONF/PASSWD #用户账号密码文件路径, can write absolute path
Authz-db=/home/svn/conf/authz #访问控制权限文件路径, can write absolute path
REALM=SVN #每个SVN项目的认证命, will be displayed in the authentication prompt, recommend write project name.
: wq! #保存退出
3, Start SVN
svnserve-d-r/home/svn--config-file/home/svn/conf/svnserve.conf--listen-port 3690
#--config-file after the global configuration parameter file
Ps-ef|grep svn|grep-v grep #查看进程
Netstat-ln |grep 3690 #检查端口
Killall svnserve #关闭svn
4, set up SVN service boot
VI/ETC/INIT.D/SVN #编辑, add the following code
#!/bin/sh #
chkconfig:2345
# processname:svn
svn_bin=/usr/local/svn/bin
svn_port=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", "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)
$ stop
$ start
;;
*)
echo "USAGE:SVN {start | Stop | Restart} "
exit 1
Esac
: wq! #保存退出
chmod +x/etc/init.d/svn #添加执行权限
Chkconfig svn on #开机自启动
Service svn start #启动
Vi. Configuring SVN to support HTTP access
1, create account 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 2 times according to the prompts.
Attention:
/home/svn/conf/directory below the passwd file is a svnserve independent server to use the authentication file, the password is not encrypted, clear text display.
The/home/svn/conf/directory below http_passwd file is the Apache HTTP mode used by the authentication file, the password used MD5 encryption.
passwd and http_passwd files, the account password must be set to the same.
2, set the Apache configuration file
Vi/etc/httpd/conf.d/subversion.conf #编辑, add the following code at the end
<Location/svn>
DAV SVN
#SVNPath/HOME/SVN
Svnparentpath/home/svn
# # Limit Write permission to list of valid users.
# <limitexcept Get PROPFIND OPTIONS report>
# # 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
# </LimitExcept>
</Location>
: wq! #保存退出
3, set directory permissions
Chown apache:apache/home/svn-r #设置svn目录所有者为Apache服务运行账号apache
4, restart the Apache service
Service httpd restart #重启
Vii. Test SVN
Install the SVN client tortoisesvn under Windows.
TortoiseSVN Download Address: http://tortoisesvn.net/downloads.html
After Setup completes, desktop-right click, select tortoisesvn-Version Library browser
URL Input: Svn://192.168.21.134/project1
User name: Osyunwei1
Password: 123456
Check: Save authentication
Are you sure
You can enter the Project1 version Library directory, and after right-clicking, you can choose to create a folder, and so on.
URL Input: Http://192.168.21.134/svn/project1
Username and password the same as above, you can enter the Project1 version Library directory, right-click, you can choose to create folders 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
User name: Osyunwei2
Password: 123456
PROJECT3 Access:
Svn://192.168.21.134/project3 #svnserve独立服务器模式
Http://192.168.21.134/svn/project3 #Apache的http模式
User name: Osyunwei3
Password: 123456
Extended reading:
1, Apache htpasswd command option parameter description
-C Create an encrypted file
-N Do not update the encrypted file, only the user name password encrypted with the Apache HTPASSWD command is displayed on the screen
-M default Apache HTPASSSWD command uses MD5 algorithm to encrypt passwords
The-D Apache htpassswd command uses the crypt algorithm to encrypt passwords
-P Apache htpassswd command does not encrypt passwords, i.e. plaintext passwords
-S Apache htpassswd command uses the SHA algorithm to encrypt passwords
-B Enter the username and password together with the Apache HTPASSSWD command line instead of prompting for a password
-D deletes the specified user
2, Svnpath and Svnparentpath difference:
Svnparentpath: Supports the SVN version library of multiple identical parent directories.
Svnpath: Only the SVN version library of one home directory is supported, and if a new project is built under the home directory, the prompt does not have access.
At this point, there are two modes in which the SVN server in Linux supports Apache HTTP and svnserve standalone servers and use the same access rights account tutorial completed.