环境:CentOS 7.3.1611
分三步:
第一步:安装subversion
第二步:安装httpd
第三步:安装nginx
操作步骤:
安装subversion, 命令 -> yum -y install subversion;
创建svn目录, 命令 -> mkdir /var/svn, subversion的默认目录, 没有此目录, 启动服务会失败;
创建仓库, 命令 -> svnadmin create /var/svn/repo1;
修改认证授权策略文件svnserve.conf, 命令 -> vi /var/svn/repo1/conf/svnserve.conf, 对anon-access = read、auth-access = write、password-db = passwd、authz-db = authz取消注释;
添加svn用户, 命令 -> vi /var/svn/repo1/conf/passwd, 添加svn = svn;
给用户授权, 命令 -> vi /var/svn/repo1/conf/authz, 添加[repo1:/] svn = rw;
systemctl start svnserve.service;
windows系统可以使用TortoiseSVN访问svn://ip/repo1 ,也可以在本机使用访问, 命令 -> wget http://127.0.0.1:3690/repo1, 正常访问域名配置已生效;
安装httpd, 命令 -> yum -y install httpd;
安装httpd的svn模块, 命令 -> yum -y install mod_dav_svn;
修改httpd的配置文件, 命令 -> vi /etc/httpd/conf/httpd.conf, 搜索“LoadModule”,添加以下两行:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
在文件结束处添加以下内容:
<Location /svn>
DAV svn
SVNParentPath /var/svn
#Authentication: Basic
AuthName "Subversion repository"
AuthType Basic
AuthUserFile /etc/httpd/svn-auth.htpasswd
#Authorization: Authenticated users only
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
创建svn-auth.htpasswd文件, 并添加用户laohans, 命令 -> htpasswd -c -m /etc/httpd/svn-auth.htpasswd laohans;
将apache用户添加到root组, 命令 -> usermod -a -G root apache;
启动httpd, 命令 -> systemctl start httpd.service;
通过浏览器访问, http://ip:port/repo1;
修改httpd端口, 命令 -> vi /etc/httpd/conf/httpd.conf, 找到Listen 80, 将80修改为81;
重启httpd, 命令 -> systemctl restart httpd.service;
安装nginx, 下载nginx, 命令 -> wget https://nginx.org/download/nginx-1.12.1.tar.gz;
解压nginx, 命令 -> tar -zxvf nginx-1.12.1.tar.gz;
进入解压后的nginx目录, 执行命令 -> ./configure, 会依次出现以下错误提示:
./configure: error: C compiler cc is not found;
./configure: error: the HTTP rewrite module requires the PCRE library;
./configure: error: the HTTP gzip module requires the zlib library;
安装依赖库, 命令 -> yum -y install gcc pcre-devel zlib-devel;
再次执行命令 -> ./configure, 出现以下内容说明安装成功:
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
安装, 命令 -> make install
让nginx代理httpd, 命令 -> vi /usr/local/nginx/conf/nginx.conf, 添加以下内容:
location /svn {
proxy_pass http://127.0.0.1:81
}
启动nginx, 命令 -> /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf;
测试, 浏览器访问:http://123.207.108.213/svn/repo1;
https://www.ibm.com/developerworks/cn/java/j-lo-apache-subversion/