阿里雲搭建SVN服務器

1:安裝svnlinux

apt-get install subversionweb

 

2. 開啓svn服務器服務器

svnserve -declipse

檢查是否開啓:ps aux | grep svnservesvn

若出現以下內容:post

wkr 6537 0.0 0.0 13784 956 ? Ss 16:18 0:00 svnserve -d
wkr 7593 0.0 0.0 5784 864 pts/0 S+ 21:57 0:00 grep –color=auto svnserve加密

表示服務已開啓。(注意:必定要有第1行,只有第2行說明服務未啓動)url

中止svn服務:  killall svnservespa

 

3. 創建倉庫orm

svnadmin create /home/svnrepos
理論上,倉庫能夠創建在任何目錄中。

注意:重啓svnserve  執行 svnserve -d  -r /home

這樣在eclipse客戶端把工程導入svn的時候 url須要填寫

svn://ip/svnrepos/project_name 

若是啓動的時候帶以下參數:svnserve -d  -r  /home/svnrepos

客戶端:svn://ip/project_name  這樣子會報錯。驗證失敗

4. 修改配置文件

編輯 svnserve.conf

vi /home/svnrepos/conf/svnserve.conf

 把anon-access = read 改成 none,auth_access = write 

 password-db = passwd  authz-db = authz 的註釋去掉,還有[general]的註釋也要去掉(這個默認沒有註釋)。
注:當你去掉註釋的時候,不要簡單的把前面的#去掉,要把前面的空格一塊去掉,否則在Eclipse中使用的時候會出現配置文件格式錯誤的問題。

注意:若是authz-db = authz 這個註釋掉了,則不須要配置/home/svnrepos/conf/authz

 

5. 修改賬戶文件

vi  /home/svnrepos/conf/passwd

### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
user1 = pass1  # 輸入你定義的用戶名和密碼,密碼顯然沒有加密

6. 修改受權文件

gedit /home/svnrepos/conf/authz

修改或者輸入下面2行:

[svnrepos:/]      ##格式爲    版本庫名稱  + :/
user1 = rw

其中,repos1是倉庫名稱,user1是用戶名,rw表明讀寫。

 7.客戶端鏈接
svn co svn://ip/oplinux
用戶名密碼:rsync

8.實現SVN與WEB同步,能夠CO一個出來,也能夠直接配在倉庫中

 
1)設置WEB 服務器根目錄爲/alidata/www/webroot
 
2)checkout一份SVN
 
svn co svn://localhost/alidata/www/svndata/myproject /alidata/www/webroot
修改權限爲WEB用戶
 
chown -R www:www /alidata/www/webroot/myproject
3)創建同步腳本
 
cd /alidata/www/svndata/oplinux/hooks/
cp post-commit.tmpl post-commit
編輯post-commit,在文件最後添加如下內容
 
export LANG=en_US.UTF-8
SVN=/usr/bin/svn
WEB=/alidata/www/webroot/
$SVN update $WEB –username myname –password myname
chown -R www:www $WEB
增長腳本執行權限
 
chmod +x post-commit
這樣,咱們上傳svn後,生產站點就能立馬顯示出來了,自動化程度高了不少。
相關文章
相關標籤/搜索