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 restartweb目录
[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一下找点资源就可以轻松搞定了。如果文档有什么错误地方请留言提醒下,谢谢!