安裝Subversion, 並用Nginx代理
環境:CentOS 7.3.1611
第一步:安裝subversion
1. 安裝subversion -> yum -y install subversion;
2. 創建svn目錄 -> mkdir /var/svn, subversion的默認目錄, 沒有此目錄, 啟動服務會失敗;
3. 創建倉庫 -> svnadmin create /var/svn/repo1;
4. 修改倉庫認證策略文件 -> vi /var/svn/repo1/conf/svnserve.conf, 對anon-access = read、auth-access = write、password-db = passwd、authz-db = authz取消註釋;
5. 添加svn用戶 -> vi /var/svn/repo1/conf/passwd, 添加svn = svn;
6. 用戶授權 -> vi /var/svn/repo1/conf/authz, 添加[repo1:/] svn = rw;
7. 啟動服務 -> systemctl start svnserve.service;
8. windows系統使用TortoiseSVN訪問svn://ip/repo1 ,本機訪問 -> wget http://127.0.0.1:3690/repo1, 正常訪問說明配置已生效;
第二步:安裝httpd
1. 安裝httpd -> yum -y install httpd
2. 安裝httpd的svn模塊 -> yum -y install mod_dav_svn;
3. 修改配置文件 -> vi /etc/httpd/conf/httpd.conf
3.1 搜索“LoadModule”, 添加以下兩行:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
3.2 在文件結束處添加以下內容:
<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>
4. 創建svn-auth.htpasswd文件並添加用戶laohans -> htpasswd -c -m /etc/httpd/svn-auth.htpasswd laohans;
5. 將apache用戶添加到root組 -> usermod -a -G root apache;
6. 啟動httpd -> systemctl start httpd.service;
7. 通過瀏覽器訪問 -> http://ip:port/repo1;
8. 修改httpd端口 -> vi /etc/httpd/conf/httpd.conf, 找到“Listen 80”, 將80修改為81;
9. 重啟httpd -> systemctl restart httpd.service;
第三步:安裝nginx
1. 下載nginx -> wget https://nginx.org/download/nginx-1.12.1.tar.gz;
2. 解壓nginx -> tar -zxvf nginx-1.12.1.tar.gz;
3. 進入解壓後的nginx目錄,編譯 -> ./configure,
3.1 會依次出現以下錯誤提示:
./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;
3.2 安裝依賴庫 -> yum -y install gcc pcre-devel zlib-devel;
3.3 再次編譯 -> ./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"
4. 安裝 -> make install;
5. 讓nginx代理httpd -> vi /usr/local/nginx/conf/nginx.conf, 添加以下內容:
location /svn {
proxy_pass http://127.0.0.1:81
}
6. 啟動nginx -> /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf;
7. 通過瀏覽器訪問 -> http://ip/svn/repo1;
參考文檔:https://www.ibm.com/developerworks/cn/java/j-lo-apache-subversion/
安裝Subversion, 並用Nginx代理