centos下搭建svn的安裝過程

1. System
 
CentOS 4.x/RHEL 4CentOS 5.1/RHEL 5
2. References
 
Subversion: http://subversion.tigris.org/Version Control with Subversion: http://svnbook.red-bean.com/
3. Installation
 

[root@lucifer ~]# yum install mod_dav_svn subversion

 yum install mod_dav_svn subversion
The first thing to do is to install the packages I mentioned above. If you don't have Apache installed already, it'll go ahead and drag that down as well.
When you install from yum, there's a longer list than the two packages above that will automatically resolve themselves. Some other things will be installed automatically. Depending on your packages, your mileage may vary.
4. Configurations
 
4.1. Apache
 
Before you delve into the deep end, you need to ensure Apache is set up first. I'm assuming this is a virgin installation, so if you already have Apache things going...be careful what you change. I'm also going to explain setting this up with basic password protection. You can easily let this out, however, if you want to allow access to the repos from everyone.
First thing is make sure you open up /etc/httpd/conf/httpd.conf and at least change the ServerName directive. If you need more help or more complex configurations, then consult the Apache docs please.
[root@lucifer ~] service httpd start
[root@lucifer ~] chkconfig httpd on
Browse to your machine on the network and see if you get your test page, which you should: http://yourmachine. Working? Great, let's move along to more fun things.
4.2. Subversion's Apache configs
 
The next step is to setup some settings within Apache so Subversion and Apache play nice together. Get yourself to the example configuration file Subversion installed for you.

[root@lucifer ~] cd /etc/httpd/conf.d/
[root@lucifer ~] vim subversion.conf

# Make sure you uncomment the following if they are commented out
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

# Add the following to allow a basic authentication and point Apache to where the actual
# repository resides.
<Location /repos>
        DAV svn
        SVNPath /var/www/svn/repos
        AuthType Basic
        AuthName "Subversion repos"
        AuthUserFile /etc/svn-auth-conf
        Require valid-user
</Location>


 
The location is what Apache will pass in the URL bar. For instance: http://yourmachine/repos points to the SVNPath that you have specified. My examples are just that, so feel free to put things where you want. Make sure you save the file when you are finished editing.
Next we have to actually create the password file that you specified in the previous step. Initially you'll use the -cm arguments. This creates the file and also encrypts the password with MD5. If you need to add users make sure you simply use the -m flag, and not the -c after the initial creation.

[root@lucifer ~] htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type new password:
Adding password for user yourusername
[root@lucifer ~] htpasswd -m /etc/svn-auth-conf anotherusername
New password:
Re-type new password:
Adding password for user anotherusername

[root@lucifer ~] cd /var/www/ -- Or wherever you placed your path above
[root@lucifer ~] mkdir svn
[root@lucifer ~] cd svn
[root@lucifer ~] svnadmin create repos
[root@lucifer ~] chown -R apache.apache repos
[root@lucifer ~] service httpd restart

web目錄

[root@lucifer ~] /data0/htdocs/Aaron_DM_dashagua;chown -R apache.apache /Aaron_DM_dashagua;chmod -R 777 /Aaron_DM_dashagua;

svn導入的項目目錄

[root@lucifer ~] mkdir /Aaron_DM_dashagua;cd /Aaron_DM_dashagua;touch file1.txt;chown -R apache.apache /Aaron_DM_dashagua;chmod -R 777 /Aaron_DM_dashagua;

[root@lucifer ~] su - apache

[root@lucifer ~] svn import /Aaron_DM_dashagua file:///var/www/svn/repos -m "Aaron_DM_dashagua"

[root@lucifer ~] svn checkout /data0/htdocs/Aaron_DM_dashagua --username=用戶名 --password=密碼

[root@lucifer ~] su -root

[root@lucifer ~] cd /var/www/svn/repos/hooks;cp post-commit.tmpl post-commit;

把post-commit裏的內容全部清空;添加下面內容:

svn update /data0/htdocs/Aaron_DM_dashagua --username=用戶名 --password=密碼

最後保存退出;

[root@lucifer ~] chown apache.apache post-commit;chmod 777 post-commit

[root@lucifer ~] svnserve -d -r /var/www/svn/repos

[root@lucifer ~] server httpd restart

這時你可以測試了。測試過程:

在本地通過客戶端提交一個新增加的文件,然後到svn服務器/data0/htdocs/Aaron_DM_dashagua 目錄去看,是不是存在你增加的目錄文件;

 

對於svn權限控制的那些配置我沒有做,不過很簡單。有需要的人可以google一下找點資源就可以輕鬆搞定了。如果文檔有什麼錯誤地方請留言提醒下,謝謝!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章