安装svn相关基础环境说明:
环境:CentOS 6.3
原有服务环境:lnmpa 1.0 full
安装svn的版本: subversion 1.8.3
由于lnmpa编译的时候没有安上–enable-dav 故svn使用不了httpd的服务,我们只用svn协议来访问
同步好后再执行钩子程序同步到虚拟空间下做网站服务。
安装步骤:
各个安装包说明:
1.self 1.2.1 推荐版本,1.3.0后面会出现报错。
Subversion 1.8中http客户端基于neon已经被移除如果要支持http方式需要在安装svn前安装serf,安装serf推荐用serf-1.2.1
2.apr、apr-unit
安装apr、apr-unit
# cd /root/lamp/source
wget http://archive.apache.org/dist/apr/apr-1.4.8.tar.gz #LAMP中已经下载
wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
tar xzf apr-1.4.8.tar.gz
cd apr-1.4.8
./configure –prefix=/usr/local/apache
make && make install
cd ../
tar xzf apr-util-1.5.2.tar.gz
cd apr-util-1.5.2
./configure –prefix=/usr/local/apache
make && make install
cd ../
2.安装serf-1.2.1 (需要httpd服务才安装,下面只是参考,将不进行安装)
# yum -y install expat-devel
wget http://serf.googlecode.com/files/serf-1.2.1.tar.bz2 #serf-1.2.1.zip是win版有问题
tar xjf serf-1.2.1.tar.bz2
cd serf-1.2.1
./configure –prefix=/usr/local/serf –with-apr=/usr/local/apache –with-apr-util=/usr/local/apache
make && make install
cd ..
3.安装svn
# wget http://mirror.bit.edu.cn/apache/subversion/subversion-1.8.3.tar.gz
tar xzf subversion-1.8.3.tar.gz
cd subversion-1.8.1
./get-deps.sh //此步骤会等比较久,是配置svn服务库的脚步,完成后会出现如下提醒
If you require mod_dav_svn, the recommended version of httpd is:
http://archive.apache.org/dist/httpd/httpd-2.4.6.tar.bz2
If you require apr-iconv, its recommended version is:
http://archive.apache.org/dist/apr/apr-iconv-1.2.1.tar.bz2
./configure –prefix=/usr/local/subversion –with-apxs=/usr/local/apache/bin/apxs –with-apr=/usr/local/apache –with-apr-util=/usr/local/apache –with-zlib –with-openssl –enable-maintainer-mode –with-serf=/usr/local/serf –enable-mod-activation
make && make install
cd ..
4. 检测svn是否安装成功
# vim /usr/local/apache/conf/httpd.conf
LoadModule dav_svn_module /usr/local/subversion/libexec/mod_dav_svn.so
LoadModule authz_svn_module /usr/local/subversion/libexec/mod_authz_svn.so
5.把svn相关的命令添加到环境变量中
/ 方法一 /
ln -s /usr/local/subversion/bin/svn /usr/local/bin
//这样在ssh中直接输入 svn –version就可以看到svn的版本等信息了
/ 方法二 (未测试) /
echo “export PATH=$PATH:/usr/local/subversion/bin/“ >> /etc/profile
source /etc/profile
* svn项目配置 建立仓库
# mkdir -p /opt/svn/
mkdir -p /opt/svn/svntest/
svnadmin create /opt/svn/svntest/
或 /usr/local/subversion/bin/svnadmin create /opt/svn/mall/
/修改配置文件/
cd /opt/svn/svntest/conf/
vi svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
vim authz //给svntest仓库添加一个用户,权限为可写。
[svntest:/]
testuser = rw
vi passwd
//由于是测试,密码设置为123456
testuser = 123456
//设置好后启用svn服务
svnserve -d -r /opt/svn/
或
/usr/local/subversion/bin/svnserve -d -r /opt/svn/
//添加到开机启动
vim /etc/rc.d/rc.local
然后写入上面的代码
//查看是否启用了
netstat -tunlp | grep svn
ps -aux|grep svn
//杀死进程
kill -9 node
* SVN钩子程序设置
说明:
首先要在网站目录下检出文件
svn checkout svn://42.51.133.35/zoy/ /home/wwwroot/zoy.ch.boxcore.org/
svn update /home/wwwroot/zoy.ch.boxcore.org/
vim /opt/svn/zoy/hooks/post-commit
#!/bin/sh
SVN=/usr/local/subversion/bin/svn
WEB=/home/wwwroot/zoy.ch.boxcore.org
$SVN update $WEB –username 用户名 –password 密码
chown -R www:www $WEB
chmod 777 /opt/svn/zoy/hooks/post-commit
参考文档:
http://blog.csdn.net/xiaodanpeng/article/details/8898794
http://lookdfw.blog.163.com/blog/static/58249742201010652235834/
http://chenxiao18.blog.51cto.com/1144683/1196264 《对apache做./configure 增加参数支持svn
http://freeloda.blog.51cto.com/2033581/1189145 《SVN 安装与配置
http://www.open.collab.net/scdocs/ddUsingSVN_command-line.html.zh-cn 《linux下svn命令