New User 1: useradd -M zhangsan this way the user does not add generated by -M /home/zahngsan
home directory;
User password: passwd zhangsan 根据提示输入两次要设置的密码
2 new user groups groupadd svn
3 Add User to User Group: usermod -G svn zhangsan
4 to see if there is in accordance with SVN: svnserve --version without first according to SVN: yum -y install subversion
5 Create svn repository, initialization configuration file
mkdir -p /opt/svnrepos/code
svnadmin create /opt/svnrepos/code
Check the repository configuration file
cd /opt/svnrepos/code
ll
drwxr-xr-x. 2 root root 54 3月 2 22:49 conf
drwxr-sr-x. 6 root root 253 3月 2 22:51 db
-r--r--r--. 1 root root 2 3月 2 22:47 format
drwxr-xr-x. 2 root root 231 3月 2 22:47 hooks
drwxr-xr-x. 2 root root 41 3月 2 22:47 locks
-rw-r--r--. 1 root root 229 3月 2 22:47 README.txt
If you delete the repository:
# sudo rm -rf /opt/svnrepos/code
conf file into the code directory folder. Copy the passwd file with one of the authz to svnrepos directory
cd /opt/svnrepos/code/conf
authz cp / opt / svnrepos /
cp passwd /opt/svnrepos/
Svnserve.conf modify files in the code / conf, which will be developed with the passwd file authz development of the documentation to be modified, additional configuration to configure the normal single svn.
[General] # prohibit anonymous users to access anon-Access = NO # authorized users have read-write access auth-Access the Write = # of public passwd password-db = / opt / svnrepos / passwd # using common authz authz-db = / opt / svnrepos / authz # designated repository of domain authentication, code repository path / opt / svnrepos / code /, custom repository path is / opt / svnrepos / code /
anon-access = none: express prohibition of anonymous user access.
auth-access = write: indicates authorized users have read and write permissions.
password-db = passswd: Specifies the user name password file, namely passwd file.
authz-db = authz: assign a rights profile that authz file.
realm = / opt / svnrepos / code /: Specifies the authentication domain, i.e., / opt / svnrepos directory
6 editor svn user profile
vi /opt/svnrepos/passwd
[the Users] # harryssecret harry = # = sallyssecret Sally # username, password ADMIN ADMIN = Quest = 123456 lisi = 123456 zhangsan = 123456 wangwu = 123456 Ligang = 123456
Edit svn access control configuration file vi / opt / svnrepos / authz
[aliases] [Groups] # user group name = user name ADMIN = ADMIN Quest = Quest users_code = lisi, zhangsan users_custom = wangwu, Ligang # represents the root directory (/ opt / svnrepos /), for all repositories set permissions [/] # represents a read and write permissions to the admin group root, r is read, w is written @ admin RW = # warehouse code indicates the root directory (/ opt / svnrepos / code /) [code: /] # represents a group of the root users_code have read and write permissions, r is read, w is write @ users_code RW = # represents the test directory code repository [code: / test] # represents a group quest root read and write permissions, r is read @ = R & lt quest # represents a custom repository root directory (/ opt / svnrepos / custom /) [custom: /] # users_code group represents read and write permissions to the root directory, r is read, w is write @ users_custom = rw represent the test directory # custom warehouse [Custom: / Test] # represents a group quest root read and write permissions, r is read @ quest = r
7 in the /etc/init.d directory, create a script svnd
cd /etc/init.d
touch svnd
chmod u+x svnd
Edited svnd script is shown below
#!/bin/sh # chkconfig: 2345 10 90 # description: svn server SVN_HOME=/opt/svnrepos if [ ! -f "/usr/bin/svnserve" ] then echo "svnserver startup: cannot start" exit fi case "$1" in start) echo "Starting svnserve…" /usr/bin/svnserve -d --listen-port 3690 -r $SVN_HOME echo "Finished!" ;; stop) echo "Stoping svnserve…" killall svnserve echo "Finished!" ;; restart) $0 stop $0 start ;; *) echo "Usage: svn { start | stop | restart } " exit 1 esac
8 start svn service
[root@CentOS init.d]# service svnd start Starting svnserve… Finished! [root@CentOS init.d]# ps -ef | grep 'svnserve' root 4225 1 0 23:33 ? 00:00:00 /usr/bin/svnserve -d --listen-port 3690 -r /opt/svnrepos root 4230 3505 0 23:33 pts/0 00:00:00 grep --color=auto svnserve [root@CentOS init.d]#
After installing the svn service, the default is to not start with the system automatically activated, CentOS /etc/rc.d/rc.local 7 is not authorized to perform, the system recommends creating systemd service start service
View svnserve.service Location: systemctl enable svnserve.service
So in view systemd svn profile /lib/systemd/system/svnserve.service
[Unit] Description=Subversion protocol daemon After=syslog.target network.target [Service] Type=forking EnvironmentFile=/etc/sysconfig/svnserve ExecStart=/usr/bin/svnserve --daemon --pid-file=/run/svnserve/svnserve.pid $OPTIONS [Install] WantedBy=multi-user.target
Svn found the service configuration file / etc / sysconfig / svnserve edit the configuration file
vi /etc/sysconfig/svnserve
The OPTIONS = "- r / var / svn" svn version was changed to put the inventory directory,: wq save and exit
At the prompt, enter systemctl enable svnserve .service
shutdow -r now
-Aux input PS | grep 'svn'
Open port 3690 (svn service default port)
[root@CentOS init.d]# firewall-cmd --zone=public --add-port=3690/tcp --permanent success [root@CentOS init.d]# firewall-cmd --reload success [root@CentOS init.d]#
Using TortoiseSVN tested under windows
Such as code repository address svn
svn://192.168.2.2/code
Add the svn as a system service, and is set to boot
[root@CentOS init.d]# chkconfig --add svnd [root@CentOS init.d]# chkconfig svnd on
=============================
Configure httpd access method
Install httpd service: yum install httpd
Httpd check whether the installation was successful:
httpd -version Server version: Apache/2.4.6 (CentOS) Server built: Jul 18 2016 15:30:14
Install mod_dav_svn, mod_dav_svn is an apache svn server access module. Installation through yum:
yum install mod_dav_svn
安装成功后,会有mod_dav_svn.so和mod_authz_svn.so两个文件。
$ sudo find / -name mod_dav_svn.so /usr/lib64/httpd/modules/mod_dav_svn.so $ sudo find / -name mod_authz_svn.so /usr/lib64/httpd/modules/mod_authz_svn.so
修改svn仓库的用户组为apache
chown -R apache:apache /opt/svnrepos
创建用户文件passwd_httpd(httpd方式密码为md5加密,需重新配置用户名密码),示例如下:
touch /opt/svnrepos/passwd_http #创建用户文件 htpasswd /opt/svnrepos/passwd_httpd admin #创建用户admin htpasswd /opt/svnrepos/passwd_http guest #创建用户gues
配置httpd
touch /etc/httpd/conf.d/subversion.conf cat /etc/httpd/conf.d/subversion.conf <Location /svn> DAV svn #SVNPath定义到具体仓库位置 #SVNPath /opt/svnrepos/code #SVNParentPath 定义多个仓库 SVNParentPath /opt/svnrepos AuthType Basic AuthName "Subversion repos" #用户名密码(密码为md5加密) #AuthUserFile /opt/svnrepos/passwd_httpd AuthzSVNAccessFile /opt/svnrepos/authz Require valid-user </Location>
启动httpd服务
service httpd start
客户端使用http://192.168.2.2/svn/code就可以访问刚才建立的svn仓库了。 如果返回403错误,可能是防火墙问题。增加防火墙规则
//永久的添加该端口 firewall-cmd --permanent --zone=public --add-port=80/tcp //加载配置,使得修改有效 firewall-cmd --reload //查看开启的端口 firewall-cmd --permanent --zone=public --list-ports
https://blog.csdn.net/weixin_42231507/article/details/81149568