阿里雲搭建SVN服務器


1:安裝svn

apt-get install subversion

 

2. 開啟svn服務器

svnserve -d

檢查是否開啟:ps aux | grep svnserve

若出現如下內容:

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行說明服務未啟動)

停止svn服務:  killall svnserve

 

3. 建立倉庫

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后,生產站點就能立馬顯示出來了,自動化程度高了很多。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM