现在的位置: 首页 > 综合 > 正文

Linux配置svn,测试了,好用,但是还没有钩子自动更新的那部分,有点遗憾

2013年10月26日 ⁄ 综合 ⁄ 共 4069字 ⁄ 字号 评论关闭

http://ostechnix.wordpress.com/2013/04/30/install-subversion-server-in-centos-6-4-rhel-6-4-scientific-linux-6-4/


Install Subversion server in CentOS 6.4 / RHEL 6.4 / Scientific Linux 6.4

Subversion is a free open source version control system used to manage files/directories and the changes of them made all time. It allows us to recover the older files/directories and examine the history of your files/directories
how they are changed all over time. 

Installation

Install Subversion as shown below.
root@server ~]# yum install -y subversion mod_dav_svn
If you haven’t install apache already the above command will install it respectively.

Configure Subversion

Open the subversion config file ‘/etc/httpd/conf.d/subversion.conf’ and edit as follows.

[root@server ~]# vi /etc/httpd/conf.d/subversion.conf 
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
##Add the following lines ##
<Location /svn>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/svn-auth-users
Require valid-user
</Location>
#
# containing Subversion repositories, "/var/www/svn".  Each repository
# must be both:
#
#   a) readable and writable by the 'apache' user, and
#
#   b) labelled with the 'httpd_sys_content_t' context if using
#   SELinux
#
# Example configuration to enable HTTP access for a directory
Now create a new user for Subversion called “sk” for instance.
[root@server ~]# vi /etc/httpd/conf.d/subversion.conf 
[root@server ~]# htpasswd -cm /etc/svn-auth-users sk
New password: 
Re-type new password: 
Adding password for user sk

Create and configure Subversion Repository

Create a directory for subversion repository under ‘/var/www/’ directory.
[root@server ~]# mkdir /var/www/svn
[root@server ~]# cd /var/www/svn/
[root@server svn]# svnadmin create ostechnix_repo
[root@server svn]# chown -R apache.apache ostechnix_repo/

Note: If you enabled SELinux, run the following commands to change the SELinux
context security.

[root@server svn]# chcon -R -t httpd_sys_content_t /var/www/svn/ostechnix_repo/
[root@server svn]# chcon -R -t httpd_sys_rw_content_t /var/www/svn/ostechnix_repo/
Make sure that you have opened the apache default port ’80′ through iptables.
[root@server svn]# vi /etc/sysconfig/iptables
-A INPUT -p udp -m state --state NEW --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT

Restart the iptables to save the changes.

[root@server svn]# /etc/init.d/iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

Start/Restart Apache

[root@server svn]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[root@server svn]# chkconfig httpd on

注意:在这一步要是出现Could not open the requested SVN filesystem问题

解决方法http://www.deego.co.jp/wp/?p=18


Test Subversion

Fire up your terminal and enter the following URL http://ip-address/svn/ostechnix_repo in the address bar. Enter the username and password
of Subversion user which you have created earlier.
Now you will get the Subversion repository home page.

Disable anonymous access

If you want to disable the anonymous user to access the repository, just  edit the following line in‘ostechnix_repo/conf/svnserver.conf’ file. 
[root@server ~]# vi /var/www/svn/ostechnix_repo/conf/svnserve.conf 
## Line no 12 - Uncomment and Change to 'none' ##
anon-access = none
## Line No 27 - Uncomment to enable acess control ##
authz-db = authz

Create additional links(directories) under Subversion Repository.

Create some sample directories in any place and import them to your Subversion repository.
[root@server ~]# mkdir subversion-templates
[root@server ~]# cd subversion-templates/
[root@server subversion-templates]# mkdir softwares
[root@server subversion-templates]# mkdir updates
[root@server subversion-templates]# mkdir fixes
Now import the sub directories using the command ‘svn import’.
[root@server ~]# svn import -m 'Initial import' subversion-templates/ http://192.168.1.200/svn/ostechnix_repo/
Adding         subversion-templates/updates
Adding         subversion-templates/softwares
Adding         subversion-templates/fixes
Committed revision 2.
Now check for the changes in your repository.
Now your newly created directory structure will be listed under your main repository. Thats it.

抱歉!评论已关闭.