CentOS源码编译安装Apache 2.4.26 和 Apache Subversion 1.9.6 并配置基于Apache的SVN多项目库

CentOS源码编译安装Apache 2.4.26 和 Apache Subversion 1.9.6 并配置基于Apache的SVN多项目库

#!/bin/bash
a=$(cat /proc/cpuinfo | grep 'model name'| wc -l)
apstable=2.4.26
yum -y install gcc make epel-release pcre-devel zlib-devel lynx openssl openssl-devel
cd ~
wget http://archive.apache.org/dist//httpd/httpd-$apstable.tar.gz
tar -zxvf httpd-$apstable.tar.gz;
cd ~
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
tar zxf apr-1.5.2.tar.gz && cp -fr ./apr-1.5.2 ./httpd-$apstable/srclib/apr
tar zxf apr-util-1.5.4.tar.gz && cp -fr ./apr-util-1.5.4 ./httpd-$apstable/srclib/apr-util
cd ~
cd httpd-$apstable;
./configure \
--prefix=/usr/local/apache \
--with-mpm=prefork \
--with-included-apr \
--with-ssl \
--with-pcre \
--enable-mime-magic \
--enable-proxy \
--enable-ssl=shared \
--enable-so \
--enable-dav \
--enable-deflate=shared \
--enable-ssl=shared \
--enable-expires=shared \
--enable-headers=shared \
--enable-rewrite=shared \
--enable-static-support \
--disable-userdir \
--enable-modules=all \
--enable-mods-shared=all
make -j$a
make install
......
......

yum -y install gcc gcc-c++ unzip
wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
tar -zxvf apr-1.5.2.tar.gz;cd apr-1.5.2
cd apr-1.5.2
./configure --prefix=/usr/local/apr && make && make install

wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz;cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install

wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz;cd zlib-1.2.11
./configure --prefix=/usr/local/zlib && make && make install

wget http://apache.cs.utah.edu/subversion/subversion-1.9.6.tar.gz
tar -zxvf subversion-1.9.6.tar.gz;cd subversion-1.9.6
./get-deps.sh

单独使用
./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-zlib=/usr/local/zlib && make && make install

配合apache使用
./configure --prefix=/usr/local/svn --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-zlib=/usr/local/zlib -enable-mod-activation --with-apache-libexecdir=/usr/local/apache/modules --with-apxs=/usr/local/apache/bin/apxs --without-berkeley-db && make && make install

多项目配置
mkdir -p /var/www/svn #创建SVN目录
/usr/local/svn/bin/svnadmin create /var/www/svn/repos #创建repos版本库
/usr/local/svn/bin/svnadmin create /var/www/svn/android #创建android版本库
/usr/local/svn/bin/svnadmin create /var/www/svn/web #创建web版本库

/usr/local/apache/bin/htpasswd -c -b /var/www/svn/passwd admin 123456 #第一次创建文件和创建用户
/usr/local/apache/bin/htpasswd -b /var/www/svn/passwd admin2 123456 #添加用户
www.zhangfangzhou.cn

vi /var/www/svn/authz
[groups]
all = admin,rouser
[/]
admin2 = rw
@all = r

vi /usr/local/apache/conf/httpd.conf 默认 Subrsion 安装成功后会自动加上
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

DAV svn
SVNListParentPath on
SVNParentPath /var/www/svn
AuthzSVNAccessFile /var/www/svn/authz
AuthType Basic
AuthName "www.zhangfangzhou.cn SVN"
AuthUserFile /var/www/svn/passwd
Require valid-user

赋予权限
chown -R apache.apache /var/www/svn
chown -R apache.apache /usr/local/apache
重启服务
service httpd restart

/usr/local/apache/conf/httpd.conf: Cannot load modules/mod_dav_svn.so into server:
出现这个原因是因为没有加载#LoadModule dav_module modules/mod_dav.so

CentOS6.x YUM安装配置使用基于Apache的SVN多项目库

CentOS6.x YUM安装配置使用基于Apache的SVN多项目库

1、安装apache和svn
yum install httpd subversion mod_dav_svn -y
2、服务初始化配置
sed -i 's/^#ServerName www.example.com:80/ServerName localhost:80/' /etc/httpd/conf/httpd.conf
sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
service httpd start;chkconfig httpd on
chkconfig iptables off;service iptables stop

3、创建目录和项目目录
mkdir -p /var/www/svn #创建SVN目录
svnadmin create /var/www/svn/repos #创建repos版本库

单项目配置
cd /var/www/svn/repos/conf
htpasswd -c -b /var/www/svn/repos/conf/passwd admin 123456 第一次创建文件和创建用户
htpasswd -b /var/www/svn/repos/conf/passwd admin2 123456 添加用户

cat /var/www/svn/repos/conf/authz

[groups] #定义用户组,方便统一管理
all = admin,rouser #定义一个组叫做“all”,包含“admin”和“rouser”
[/] #定义svn版本库根目录权限(子目录继承根目录权限)
@all = r #用户组“all”中的所有用户有读权限
admin = rw #admin用户有读权限和写权限
rouser = r       #rouser有读权限

[groups]
all = admin,rouser
[repos:/]
admin2 = rw
@all = r

vi /var/www/svn/repos/conf/svnserve.conf
[general]
anon-access = none
auth-access = write
pasword-db = passwd
authz-db - authz

配置apache
cat /etc/httpd/conf.d/subversion.conf

DAV svn
SVNPath /var/www/svn/repos
AuthzSVNAccessFile /var/www/svn/repos/conf/authz
AuthType Basic
AuthName "www.zhangfangzhou.cn SVN"
AuthUserFile /var/www/svn/repos/conf/passwd
Require valid-user

赋予权限
chown -R apache.apache /var/www/svn
重启服务
service httpd restart

多项目配置
mkdir -p /var/www/svn #创建SVN目录
svnadmin create /var/www/svn/repos #创建repos版本库
svnadmin create /var/www/svn/android #创建android版本库
svnadmin create /var/www/svn/web #创建web版本库

htpasswd -c -b /var/www/svn/passwd admin 123456 #第一次创建文件和创建用户
htpasswd -b /var/www/svn/passwd admin2 123456 #添加用户

vi /var/www/svn/authz
[groups]
all = admin,rouser
[/]
admin2 = rw
@all = r

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
#上面这两条一般默认存在

DAV svn
SVNListParentPath on
SVNParentPath /var/www/svn
AuthzSVNAccessFile /var/www/svn/authz
AuthType Basic
AuthName "www.zhangfangzhou.cn SVN"
AuthUserFile /var/www/svn/passwd
Require valid-user

赋予权限
chown -R apache.apache /var/www/svn
重启服务
service httpd restart

#如果开启安全上下文,那么需要同步安全上下文
chcon -R -t httpd_sys_content_t /var/www/html/svn

配置中有 SVNPath 与 SVNParentPath 两个选项.
SVNPath用于只有一个项目的情况,此时如果在主目录下面再建新项目,则不能访问.提示没有权限.
如果有多个项目的话,此时应该使用SVNParentPath来设置父目录来设置项目的父目录,这样子目录里面可以有多个项目了。然后auth文件里面可以定义子目录的权限。
apache的/etc/httpd/conf.d/subversion.conf 配置文件里面设置一个location就可以了