一、安装apache
1.检查apache是否安装
rpm -qa|grep httpd
2.使用yum安装apache
yum -y install httpd
3.记住安装的版本号
httpd.x86_64 0:2.4.6-31.el7.centos
4.启动apache测试apache是否可用
systemctl start httpd.service systemctl status httpd.service
5.浏览器输入IP查看是否能显示以下页面
6.apache安装路径
/etc/httpd
二、安装SVN
1.检查svn是否安装
rpm -qa|grep subversion
2.安装svn:
yum install subversion
3.使用命令查看版本
svnserve --version
4.记住版本号svnserve,版本 1.7.14 (r1542130)
5.安装apache对svn的支持模块
yum install mod_dav_svn #安装完成后apache的modules目录下会多两个文件 mod_authz_svn.so mod_dav_svn.so
6.安装python对svn的支持
yum install subversion-python
三、Apache+Svn结合
1.创建svn仓库
[root@localhost ~]# svnadmin create /svndir [root@localhost ~]# cd /svndir/ [root@localhost svndir]# ls conf db format hooks locks README.txt [root@localhost svndir]# cd conf/ [root@localhost conf]# ls authz passwd svnserve.conf
2.验证安装
查看httpd的版本:
[root@localhost home]# httpd -version Server version: Apache/2.4.6 (CentOS) Server built: Jun 27 2018 13:48:59
检测apache是否加载svn模块:
[root@localhost home]# ls /etc/httpd/modules/ |grep svn mod_authz_svn.so mod_dav_svn.so
如果没有加载svn模块,请添加以下配置:subversion.conf有就直接编辑,没有就添加。
[root@localhost home]# cd /etc/httpd/conf.d/ [root@localhost conf.d]# ll total 20 -rw-r--r-- 1 root root 2926 Jun 27 21:48 autoindex.conf -rw-r--r-- 1 root root 366 Jun 27 21:49 README -rw-r--r-- 1 root root 344 Sep 27 13:44 subversion.conf -rw-r--r-- 1 root root 1252 Jun 27 02:07 userdir.conf -rw-r--r-- 1 root root 824 Jun 27 02:07 welcome.conf [root@localhost conf.d]# vim subversion.conf
subversion.conf内容如下:/repos表示 : http://ip:端口号/repos
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location /repos> DAV svn SVNPath /home/svn AuthType Basic AuthName "Authorization svn" AuthUserFile /home/svn/authz/authz.conf AuthzSVNAccessFile /home/svn/authz/access.conf Require valid-user </Location>
3.配置
创建仓库用户和用户组都赋予apache
[root@localhost conf.d]# cd /home/ [root@localhost home]# chown -R apache:apache svn
创建密码文件:
[root@localhost home]# mkdir /home/svn/authz/ [root@localhost home]# touch /home/svn/authz/authz.conf
生成账号:
[root@localhost home]# htpasswd /home/svn/authz/authz.conf zhangqigao
分配权限:
[root@localhost home]# touch /home/svn/authz/access.conf
access.conf添加配置如下:
[groups] admin = zhangqigao [/] @admin = rw [svn:/] zhangqigao = rw
重启apache:
[root@localhost home]# service httpd restart #/bin/systemctl restart httpd.service centos7.0
然后访问如下:http://192.168.200.158:81/repos