|
一、下载软件:
subversion-1.7.14.tar.bz2
apr-1.4.6.tar.bz2
apr-util-1.5.1.tar.bz2
sqlite-amalgamation-3.7.3.tar.gz
httpd-2.2.26.tar.bz2
pcre-8.10.tar.bz2
expat2.tar.gz
二、安装所依赖的包:
1、安装apr
# tar vjxf apr-1.4.6.tar.bz2
# cd apr-1.4.6
# ./configure –prefix=/usr/local/apr
# make&&make install 2、安装apr-util
# tar vjxf apr-util-1.5.1.tar.bz2
# cd apr-util-1.5.1
# ./configure –with-apr=/usr/local/apr/ --
# make&&make install 3、安装sqlite
# tar vzxf sqlite-amalgamation-3.7. 3.tar.gz
# cd sqlite-3.7. 3
# ./configure
# make&& make install 4、安装prce
#tar xfpcre-8.10.tar.bz2
#cd pcre-8.10
#./configure –prefix=/usr/local/pcre
#make && make install 5、安装expat
下载 expat:http://sourceforge.net/project/showfiles.php?group_id=10127
#cd /usr/local
#tar -xvzf expat2.tar.gz
#cd expat2
#./configure
#make &&make install 6、安装neno
wget http://www.webdav.org/neon/neon-0.25.5.tar.gz
#tar xf neon-0.25.5.tar.gz
#cd neon-0.25.5
#./configure --with-ssl --prefix=/usr/local/neon
#make &&make install 三、安装apache+svn
1、安装apache (在此说明,应先安装apache在安装svn)
#tar xf httpd-2.2.26.tar.bz2
#cd httpd-2.2.26
#./configure --prefix=/usr/local/apache --enable-dav --enable-so --sysconfdir=/etc/httpd --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config --with-pcre=/usr/local/pcre --enable-maintainer-mode --enable-rewirte
#make && make install 修改httpd的主配置文件,设置其Pid文件的路径
编辑/etc/httpd/httpd.conf,添加如下行即可:
PidFile"/var/run/httpd.pid"
提供SysV服务脚本/etc/rc.d/init.d/httpd,内容如下:
#!/bin/bash
#
# httpdStartup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.It is used to serve \
#HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL 而后为此脚本赋予执行权限:
# chmod +x /etc/rc.d/init.d/httpd
启动httpd服务
#service httpd start
然后在浏览器输入对应的IP访问,显示It's works 则说明服正常
2、安装svn
# tar vjxf subversion-1.7.14.tar.bz2
# cd subversion-1.7.14
#./configure--prefix=/usr/local/subversion--with-apr=/usr/local/apr/
--with-apr-util=/usr/local/apr-util/ --with-apxs=/usr/local/apache/bin/apxs
# make && make install
# ls /usr/local/subversion/
bin/include/ lib/share/
添加环境变量:
#vi /etc/profile
export SVNPATH=$PATH:/usr/local/subversion
export $PATH:$SVNPATH/bin
#source /ect/profile
测试SVN是否安装成功,执行如下
#svnserve --version 如果显示版本信息, 则安装成功.
四、整合svn和apache
查看apache是否可以加载svn的模块
#ls /usr/local/apache/modules/ | grep svn
mod_authz_svn.so
mod_dav_svn.so 有此模块说明apache可以加载svn
1、创建SVN仓库
# 运行创建版本库的命令,指定数据存储为 FSFS,如果要指定为 Berkeley DB,则将 fsfs 替换为 bdb
$ svnadmin create /data/svn/fax_repos
2、整合apache和subversion
Subversion服务器有两种运行方式,一是可以作为Apache 2.0的一个模块,以WebDAV/DeltaV协议与外界连通;另外,也可使用Subversion 自带的小型服务器程序svnserve。
以http方式运行
在/etc/httpd/httpd.conf中加入:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
DAV svn
SVNPath /data/svn
在服务器的浏览器中输入网址: http://localhost/svn/fax_repos
这时候,你会看到reversion0的界面,说明仓库就已经可以工作了。
tips:此时如果不能看到,请小心检查以上几步,如果都正确,请检查自己的httpd.conf配置文件,其中检查apache调用svn的端口是否占用,因为linux自带的web服务占用的是80端口,而apache默认调用的也是80端口。
3、用户添加以及权限设置1.用户添加:
因为subversion跟apache整合在一起,所以用户添加管理和权限设置都是apache的任务。
进入/urs/local/apaceh2/bin,添加用户
# ### 第一次: 以 -c 建立档案
# htpasswd -c /data/svn /svn-auth-file svnbakup
New password: *****
Re-type new password: *****
Adding password for user svnbakup
# htpasswd /data/svn/svn-auth-file svnfax
New password: *******
Re-type new password: *******
Adding password for user svnfax
2.用户权限添加
在/usr/local/apache2/conf/httpd.conf的加入:
DAV svn
SVNListParentPath on/显示根目录下列表
SVNPath /data /svn/svn父目录
AuthType Basic/连接类型设置
AuthName "Subversion repository"/提示框
AuthUserFile /etc/svn-auth-file/权限配置文件
Require valid-user/采用何种认证
//其中authfile是通过"htpasswd [–c] /home/svnroot/repository/authfile username password"来创建的
//"Require valid-user"告诉apache在authfile中所有的用户都可以访问。如果没有它,
//则只能第一个用户可以访问新建库
重新启动 Apache后,如果有人要访问SVN服务器,系统会要求他输入用户名和密码。只有输入Sally 或Harry的用户名和相应的密码,才可以对档案库进行修改和访问。
权限设置在svn-auth-file内
比如仓库rpo,其下有p1,p2两个目录,用户有a,b
#用户a,b只能对rpo目录下的目录进行read,没有权限write
[rpo:\]
a = r
b = r
#用户a对p1有读写的功能,用户b只能读
[doc:/p1]
a = rw
b = r
tips:请注意用户会继承上级目录的权限。小心设置,不要相互冲突。
此时用户登录只需要输入正确的用户名和密码即可登录,如果不能访问,看以下说明:
tips:看你的用户是否有查看文件的权限,使用命令#chown –R apache.apache /path/to/file
用户组和用户组权限设置
用户组添加如下:
[groups]
Ppc = a, b, c
Symbian = d, e, f
用户组权限设置要在前面添加@标志,表示对组内所有成员权限一样
[doc:/]
@symbian = r
五、在安装过程中出现的错误以及解决方案
出错1:如下所示
在进行初始化的时候报错误,查了下是说缺少组件neon
安装 neon
wget http://www.webdav.org/neon/neon-0.25.5.tar.gz
./configure --with-ssl --prefix=/usr/local/neon
make&&make install
出错2:如下图所示:
configure: error: no XML parser was found: expat or libxml 2.x required
错误提示需要安装expat
下载expat :http://sourceforge.net/project/showfiles.php?group_id=10127
#tar -xvzf expat2.tar.gz
#cd expat2
#./configure
#make&&make install
svnsync备份
svn的三种备份方式
完全备份
svnadmin hotcopy [备份目录] [原版本库目录]
增量备份
备份命令:
svnadmin dump [源版本库目录] –version [需要备份的版本号] –incremental >[保存了本次备份版本号包含的增量数据文件]
恢复命令:
svnadmin load [源版本库目录,需要恢复数据的目录] |
|
|