天天看點

Linux CentOS 6.5 x64 SVN伺服器搭建

Linux CentOS 6.5 x64 SVN伺服器搭建步驟

1. 安裝Subversion

yum install subversion
           

注意:安裝需要使用root權限,否則會提示You need to be root to perform this command.英文也很簡單,這裡就不多廢話了。

2. 檢視Subversion的安裝位置

rpm -ql subversion
           

我們看到在bin目錄下放有可執行的指令:

Linux CentOS 6.5 x64 SVN伺服器搭建

可以通過檢視SVN版本來确認是否已經安裝成功,輸入如下指令:

svn --version
           
Linux CentOS 6.5 x64 SVN伺服器搭建

3. 确定SVN版本庫存放位置,我選擇使用/var/svn/repository

mkdir -p /var/svn/repository
           

4. 在指定位置(/var/svn/repository)建立版本庫

svnadmin create /var/svn/repository
           

版本庫建立成功後,在版本庫目錄中會生成如下檔案:

Linux CentOS 6.5 x64 SVN伺服器搭建

5. 進入conf目錄(該svn版本庫配置檔案) authz -- 檔案是權限控制檔案 passwd -- 帳号密碼檔案 svnserve.conf -- SVN服務配置檔案

6. 配置

設定賬号密碼,打開passwd檔案
vim passwd
           
Linux CentOS 6.5 x64 SVN伺服器搭建

在[users]塊下添加一行username = password, 此處格式為:使用者名 = 密碼,例如:admin = password

設定權限,打開authz檔案

vim authz
           
Linux CentOS 6.5 x64 SVN伺服器搭建
在最後添加:
[/]
admin = rw
           

說明:

[/] -- 版本庫根目錄

admin = rw -- admin使用者有讀寫權限

使用者組設定為同樣道理,大家自己研究吧,這裡就不多說了。

設定配置檔案svnserve.conf

vim svnserve.conf
           
Linux CentOS 6.5 x64 SVN伺服器搭建
打開如上紅色框中的幾行注釋: anon-access = read #匿名使用者可讀 auth-access = write #授權使用者可寫 password-db = passwd #使用哪個檔案作為賬号檔案 authz-db = authz #使用哪個檔案作為權限檔案 realm = /var/svn/repository # 認證空間名,我們最初設定的版本庫所在的目錄

7. 配置防火牆端口

預設端口為3690

vi /etc/sysconfig/iptables
           

添加以下内容:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
           

儲存後重新開機防火牆

service iptables restart
           

8. 啟動SVN版本庫

svnserve -d -r /var/svn/repository/
           

9. 檢視SVN程序

[[email protected] conf]# ps -ef|grep svn|grep -v grep
root     12538     1  0 14:40 ?        00:00:00 svnserve -d -r /opt/svn/repositories
           

10. 檢測SVN 端口

[[email protected] conf]# netstat -ln |grep 3690
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN
           

11. 停止重新開機SVN

[[email protected] password]# killall svnserve    //停止
[[email protected] password]# svnserve -d -r /opt/svn/repositories  // 啟動 
           

12. 測試

位址:svn://127.0.0.1

預設端口:3690

13. 問題

a. 送出時提示Error: Can't open file '/var/svn/repository/db/txn-current-lock': Permission denied的解決

根源:/var/svn目錄下的一切子目錄和檔案都是屬于root使用者的

解決辦法:把/var/svn目錄下的所有檔案和子目錄添加讀寫權限

chmod –R o+rw /home/svn
           

延伸問題:is not in the sudoers file.  This incident will be reported.

1.切換到root使用者下,怎麼切換就不用說了吧,不會的自己百度去.

2.添加sudo檔案的寫權限,指令是:

chmod u+w /etc/sudoers
           
3.編輯sudoers檔案
vi /etc/sudoers
           

找到這行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (這裡的xxx是你的使用者名)

ps:這裡說下你可以sudoers添加下面四行中任意一條

youuser            ALL=(ALL)                ALL

%youuser           ALL=(ALL)                ALL

youuser            ALL=(ALL)                NOPASSWD: ALL

%youuser           ALL=(ALL)                NOPASSWD: ALL

第一行:允許使用者youuser執行sudo指令(需要輸入密碼).

第二行:允許使用者組youuser裡面的使用者執行sudo指令(需要輸入密碼).

第三行:允許使用者youuser執行sudo指令,并且在執行的時候不輸入密碼.

第四行:允許使用者組youuser裡面的使用者執行sudo指令,并且在執行的時候不輸入密碼.

4.撤銷sudoers檔案寫權限,指令:

chmod u-w /etc/sudoers
           
這樣普通使用者就可以使用sudo了.

如有不對的地方歡迎大家支出,交流學習。

繼續閱讀