ubuntu下安裝SVN

1。安裝subversion和apache2的組件(已經認爲您已經安裝了apache2),

sudo apt-get install subversion subversion-tools  libapache2-svn



在/etc/apache2/mods-enabled中會多出來一下幾個鏈接文件(實際文件在mods-available中,我們不需要去管,只需要關注enabled目錄就成):

dav_fs.load dav_svn.conf dav_fs.conf dav.load dav_svn.load


2。建立svn數據庫

sudo svnadmin create /var/svn 



ls /var/svn

你將得到這樣的結果,則說明建立成功
conf dav db format hooks locks README.txt


3。配置apache


cd /etc/apache2/mods-enabled
sudo vi dav_svn.conf
 




按照提示去掉一些文件註釋,最終的文件看起來如下


# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.

# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
<Location /svn>

  # Uncomment this to enable the repository,
    DAV svn

  # Set this to the path to your repository
    SVNPath /var/svn

  # The following allows for basic http authentication.  Basic authentication
  # should not be considered secure for any particularly rigorous definition of
  # secure.

  # to create a passwd file
  # # rm -f /etc/apache2/dav_svn.passwd
  # # htpasswd2 -c /etc/apache2/dav_svn.passwd dwhedon
  # New password:
  # Re-type new password:
  # Adding password for user dwhedon
  # #

  # Uncomment the following 3 lines to enable Basic Authentication
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.passwd

  # Uncomment the following line to enable Authz Authentication
  # AuthzSVNAccessFile /etc/apache2/dav_svn.authz

  # The following three lines allow anonymous read, but make
  # committers authenticate themselves.

  <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  </LimitExcept>

</Location>
 

或者象這樣來實現獨立的域名情況:

<VirtualHost 127.0.0.10>
        ServerName svn.rollenc.com
        DocumentRoot /var/svn

      <Location />
                DAV svn
                SVNPath /var/svn
                AuthType Basic
                AuthName "Subversion Repository"
                AuthUserFile /etc/apache2/dav_svn.passwd
                <LimitExcept GET PROPFIND OPTIONS REPORT>
                        Require valid-user
                </LimitExcept>
        </Location>
</VirtualHost>
 



4。建立密碼文件
建立第一個用戶需要加-c參數


sudo htpasswd2 -c /etc/apache2/dav_svn.passwd username
 


輸入兩次密碼
建立其他用戶:


sudo htpasswd2 /etc/apache2/dav_svn.passwd username2
 


注意沒有加-c,加-c的話會清除掉以前存在的密碼。
如果username2爲已存在用戶,那這句命令的意義就是修改密碼

5.重啓apache

sudo apache2 -k restart


如果一切正常的話,使用瀏覽器打開http://127.0.0.1/svn 應該看到如下信息
Revision 0: /
Powered by Subversion version 1.3.1 (r19032).


OK,安裝完成
你可以對他進行一些import,commit等操作了

導入版本的文件框架

mkdir -p tmp/lab.rollenc.com/trunk tmp/eemap/trunk #如果你有其他已經寫好的需要一起導入的文件,cp過來讓在相應的trunk目錄下,然後下一步。
svn import tmp http://127.0.0.10/ #更具提示輸入message信息和用戶,密碼。
 

我在實驗時發現有權限問題,這是你可能需要修改/var/svn的權限爲可讀寫

sudo chmod -R 777 /var/svn
 

然後再繼續執行上面的import操作。
現在使用瀏覽器打開http://127.0.0.10,可以得到

Revision 1: /

* eemap/
* lab.rollenc.com/


繼續checkout和commit吧,祝你有一個愉快的subversion。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章