大概步骤
- 搭建svn服务
- 使用Apache HTTP服务将svn协议转成http协议
- nginx转发http请求到apache http服务
详细步骤
- 安装必要程序
yum install httpd subversion mod_dav_svn -y
- 创建svn库
mkdir -p /svn/project
svnadmin create /svn/project
cd /svn/project/conf/
- 增加用户名和密码
vi passwd
- 配置用户组和使用权限
vi authz
- 配置svnserve.conf
anon-access = none#匿名用户可读
auth-access = write #授权用户可写
password-db = passwd #使用哪个文件作为账号文件
authz-db = authz #使用哪个文件作为权限文件
realm = /svn/project # 认证空间名,版本库所在目录
6 .启动svn
svnserve -d -r /svn/project
# 停止svn:killall svnserve
# 如果提示找不到killall:yum install psmisc
- 设置为自启动
systemctl enable svnserve
- 在httpd下创建svn.conf配置文件
cd /etc/httpd/conf.d/
vi svn.conf
增加如下内容
<Location /svn/project>
DAV svn
SVNPath /svn/project
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /svn/project/conf/passwdfile
AuthzSVNAccessFile /svn/project/conf/authz
Require valid-user
SVNAdvertiseV2Protocol Off
</Location>
- 配置http用户名密码认证文件/svn/project/conf/passwdfile
# -c表示创建 -m表示密码用md5加密,这里的用户名密码要跟passwd保持一致,需要根据提示输入两次密码
htpasswd -c /svn/project/conf/passwdfile user1
htpasswd /svn/project/conf/passwdfile user2
htpasswd -b /svn/project/conf/passwdfile user2 password 不必再次输入密码
- 配置/etc/httpd/conf/httpd.conf
service iptables stop && setenforce 0
vim /etc/httpd/conf/httpd.conf
# 这里需要配置Listen和ServerName
Listen = 86
ServerName = 127.0.0.1:86
- 重启httpd服务
systemctl restart httpd
# 或httpd -k start/restart
- 配置nginx
vim /usr/local/nginx/conf/nginx.conf
增加 location /svn/project
server {
listen 80;
server_name localhost ;
location /svn/project {
proxy_pass http://127.0.0.1:86/svn/project;
# 上传文件不能超过100m
client_max_body_size 100m;
}
location / {
return 404;
}
}
- 重启nginx
nginx -s reload
- 可配置多个仓库
/etc/httpd/conf.d/svn.conf中增加多个Location节点,nginx中增加对应location