ansible+nginx+apache+svn自動化發布
ansible+nginx+apache+svn自動化發布(隱藏真實ip以及路徑)
一.ansible根據以下網址進行安裝
http://blog.51cto.com/8999a/1965139
二.nginx+apache+svn安裝
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install httpd subversion mod_dav_svn nginx -y
htpasswd -cm /etc/svn-auth-accounts root
mkdir /var/www/svn
cd /var/www/svn
svnadmin create repo
cd /repo/conf
vim svnserve.conf
將註釋打開
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = repo
設置anon-access = none #可以打開查看日誌
vim passwd
創建用戶密碼 我這用的就是上面的root
root = qqqqqq
vim authz
[/]
root = rw
chown -R apache.apache repo/
vim /etc/httpd/conf/httpd.conf
Listen 90
把監聽端口改一下 這裏改成90
在文件末尾添加
<Location /svn>
DAV svn
SVNParentPath /var/www/svn/
AuthType Basic
AuthName "SVN Repository"
AuthUserFile /etc/svn-auth-accounts
AuthzSVNAccessFile /var/www/svn/repo/conf/authz
</Location>
/etc/init.d/httpd restart
cd /mnt/
mkdir test
cd test/
touch aaa
touch bbb
touch qqq
cd ..
cd -
svn import -m "FIsasda" /mnt/test/ file:///var/www/svn/repo/test
測試可以直接編輯
vim /etc/nginx/conf.d/default.conf
server {
listen 80 ;
server_name svn.test33.com; #這個填寫域名以及解析到你服務器的ip
location / {
proxy_set_header?Host?$host;
proxy_set_header?X-Real-IP?$remote_addr;
#proxy_set_header?X-Forwarded-Proto?https; 沒用https所以我這註釋了
proxy_set_header?X-Forwarded-For?$proxy_add_x_forwarded_for;
proxy_pass?http://localhost:90; #這個就是反向代理到apache進行處理
}
/etc/init.d/httpd restart
/etc/init.d/nginx restart
輸入這個地址就可以進行訪問就代表成功部署
http://svn.test33.com/svn/repo/test
ansible要跟svn設置免密鑰登陸以及svn要跟需要發布代碼的後端服務器進行設置免密鑰登陸
ansible設置免密鑰
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@svn服務器ip #把公鑰拷貝到svn上
svn設置免密鑰登陸
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@後端服務器ip #把公鑰拷貝到svn上
這些設置好的話,就可以設置自動發布了
ansible+nginx+apache+svn自動化發布