源码搭建SVN+Apache+Setpass

1.安装配置apache2.2.18
http://download.csdn.net/download/YH555/3299526
tar xf httpd-2.2.18.tar.bz2
cd httpd-2.2.18
./configure --prefix=/yc/usr/local/apache2 --enable-so \
--enable-dav --enable-dav-fs --enable-maintainer-mode \
--with-included-apr --enable-rewrite --enable-ssl --enable-proxy \
--enable-proxy-http
-----------------------------------------------------------------
注释:
--enable-so 开启动态库支持,svn要求apache必须启用so
--enable-dav --enable-dav-fs 是支持svn认证使用的
--enable-maintainer-mode 开启调试模式
--with-included-apr 使用内置的apr
--enable-rewrite 开启rewrite
--enable-ssl 开启SSL
--enable-proxy 开启proxy支持
--enable-proxy-http 开启proxy http支持
-----------------------------------------------------------------
make && make install
创建用户
useradd -M apache
修改httpd.conf
#vim /yc/usr/local/apache2/conf/httpd.conf
User apache
Group apache
添加启动脚本
cp /yc/usr/local/apache2/bin/apachectl /etc/init.d/httpd
sed -i '2a# chkconfig: 35 85 40' /etc/init.d/httpd
sed -i '3a# description: this is http server - httpd-2.2.18.tar.gz'  /etc/init.d/httpd
chkconfig --add httpd

2.安装配置php5.5.26
tar xf php-5.5.26.tar.gz
cd php-5.5.26
./configure --prefix=/yc/usr/local/php-5.5.26 --with-config-file-path=/yc/usr/local/php-5.5.26/etc \
--with-apxs2=/yc/usr/local/apache2/bin/apxs --enable-mbstring --with-bz2 --with-zlib --with-curl \
--enable-ftp --enable-bcmath --enable-calendar --enable-sockets --disable-ipv6 --enable-dom \
--enable-xml --enable-fpm --with-libdir=lib64 --with-mysql=mysqlnd --with-gd --enable-gd-native-ttf \
--with-png-dir=/yc/usr/local --with-jpeg-dir=/yc/usr/local --with-freetype-dir=/yc/usr/local \
--with-iconv-dir=/yc/usr/local --with-gettext --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-libxml-dir=/yc/usr/local
make && make install 

3.安装配置subversion
wget http://subversion.tigris.org/downloads/subversion-1.6.13.tar.bz2
wget http://subversion.tigris.org/downloads/subversion-deps-1.6.13.tar.bz2
----------------------------------------------------------------------------------------------------
注释:
subversion-deps-1.6.13.tar.bz2是subversion的依赖包,解压后会自动放在先解压的subversion-1.6.13目录中;
----------------------------------------------------------------------------------------------------
tar xf subversion-1.6.13.tar.bz2
tar xf subversion-deps-1.6.13.tar.bz2
cd subversion-1.6.13
./configure --prefix=/yc/usr/local/subversion --with-apxs=/yc/usr/local/apache2/bin/apxs \
--with-apr=/yc/usr/local/apache2/bin/apr-1-config --with-apr-util=/yc/usr/local/apache2/bin/apu-1-config
make && make install
--------------------------------------------------------------
注释:
make报错如下:
make[1]: *** [test/serf_get] 错误 1
make[1]: Leaving directory /root/build/subversion-1.6.11/serf
make: *** [external-all] 错误 1
解决办法:
yum -y install expat-devel
---------------------------------------------------------------
配置环境变量subversion
#vim /etc/profile.d/subversion.sh
SVN_HOME=/yc/usr/local/subversion
export PATH=$SVN_HOME/bin:$PATH
source /yc/usr/local/subversion

4.整合apache+subversion
查看/yc/usr/local/apache2/modules目下是否存在以下两个模块:
mod_dav_svn.so
mod_authz_svn.so
编辑httpd.conf文件
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
Include conf/extra/httpd-svn.conf
编辑httpd-svn.conf文件
[root@svn svn]#vim /yc/usr/local/apache2/conf/extra/httpd-svn.conf 
<Location /svn>
DAV svn
SVNListParentPath On
SVNParentPath /yc/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /yc/svn/conf/pwd.conf
AuthzSVNAccessFile /yc/svn/conf/authz.conf
Require valid-user
</Location>

5.配置版本库
#mkdir -pv /yc/svn/{ops,devps}
#svnadmin create /yc/svn/ops/  --运维安全版本库目录
#svnadmin create /yc/svn/devps/  --开发版本库目录
#chown -R apache.apache /yc/svn/ops
#chown -R apache.apache /yc/svn/devps
[root@svn ~]# grep -Ev '^#|^$' /yc/svn/ops/conf/svnserve.conf
[general]
anon-access = none
password-db = /yc/svn/conf/pwd.conf
authz-db = /yc/svn/conf/authz.conf
realm = Ops Repository
[root@svn ~]# grep -Ev '^#|^$' /yc/svn/devps/conf/svnserve.conf 
[general]
anon-access = none
auth-access = write
password-db = /yc/svn/conf/pwd.conf
authz-db = /yc/svn/conf/authz.conf
realm = Devps Repository
-------------------------------------
注释:
使用统一用户密码文件和权限分配文件
-------------------------------------
生成用户密码文件pwd.conf
htpasswd -cm /yc/svn/conf/pwd.conf admin --第一次需要-c选项,-m使用md5加密
[root@svn ~]# cat /yc/svn/conf/pwd.conf 
admin:$apr1$EbKVwuNC$5mkRimnpTi7sZrC6piw2m.
fangty:$apr1$zJGXhFS9$XMl1J4VC/NZuYxUmW0Y701
handetian:$apr1$o4tkLr8k$G7L8qPTF2dIihQPIICUlJ0
weigenhui:$apr1$CWGKhUQ6$Pl4s9iuqeSsvMm33C4rZt/
fengyong:$apr1$qEv5ECgA$Pw7H2IGxqzPN9Poke2wEQ1
qiumingchun:$apr1$AOwewnHP$TD5qkYmlhN03oKL.snWDg1
mouzunkui:$apr1$ueV/0iZF$Llmd9/mg4Y7KuB.9tGnk8.
liyuan:$apr1$y3cMvWiF$TvMqUBM4mdmlkef08uRzx/
jijuntao:$apr1$McKZiG94$Zhbc4HzQJWohvXFqLTgjS/
zhangyang:$apr1$DnOkBnWh$FX7vty6ILU35yT0P.l5q.0
renfufei:$apr1$fvBGY2fF$bcTS9bjrFZaABunZhNYLB1
配置权限分配文件authz.conf
[root@svn ~]# cat /yc/svn/conf/authz.conf 
[groups]
sysusers = admin
ops = fangtianying,weigenhui,handetian,qiumingchun,fengyong,mouzunkui,liyuan,jijuntao,zhangyang
devps = renfufei
[/]
@sysusers = rw
[ops:/]
@ops=rw
[devps:/]
@devps = rw
启动服务
svnserve -d -r /yc/svn/

6.使用php页面实现SVN用户修改密码
修改httpd-svn.conf文件,添加如下内容
#vim /yc/usr/local/apache2/conf/extra/httpd-svn.conf
Alias /svntools "/yc/usr/local/apache2/htdocs/setpass"
<Directory "/yc/usr/local/apache2/htdocs/setpass">
Require valid-user
AuthType Basic
AuthName "SVN set passwd"
AuthUserFile "/yc/svn/conf/pwd.conf"
</Directory>
用户访问http://10.11.100.209/setpass修改用户密码
wget http://pan.baidu.com/s/1kTs5RhX
 
随机生成密码
cat /dev/urandom |sed 's/[^a-zA-Z0-9]//g' |strings -n 4 |head -n 5
*注释 4 代表字符数量,5代表行数
posted @ 2016-05-04 11:57  xkops  阅读(380)  评论(0编辑  收藏  举报