CentOS 7 安装SVN并整合HTTP访问

#!/bin/bash
## -------------------------------------------------
## 安装svn并整合http访问
## -------------------------------------------------


echo -e "33[1;36m安装apache33[0m"
cd /data/software
yum install expat expat-devel
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.2.tar.gz
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.0.tar.gz
wget http://mirrors.shuosc.org/apache/httpd/httpd-2.4.27.tar.gz
tar xvf apr-1.6.2.tar.gz
tar xvf apr-util-1.6.0.tar.gz
tar xvf httpd-2.4.27.tar.gz
/bin/cp -rf apr-1.6.2 httpd-2.4.27/srclib/apr
/bin/cp -rf apr-util-1.6.0 httpd-2.4.27/srclib/apr-util
cd httpd-2.4.27
./configure --prefix=/opt/apache --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

echo -e "33[1;36m安装subversion33[0m"
cd /data/software
wget http://www.sqlite.org/2017/sqlite-amalgamation-3200100.zip
wget http://mirrors.shuosc.org/apache/subversion/subversion-1.9.7.tar.gz
tar xvf subversion-1.9.7.tar.gz
unzip sqlite-amalgamation-3200100.zip
/bin/cp -rf sqlite-amalgamation-3200100 subversion-1.9.7/sqlite-amalgamation
cd subversion-1.9.7
./configure --prefix=/opt/subversion --with-apxs=/opt/apache/bin/apxs --with-apr=/opt/apache/bin/apr-1-config --with-apr-util=/opt/apache/bin/apu-1-config
make
make install
/bin/cp -raf subversion/mod_authz_svn/.libs/mod_authz_svn.so /opt/apache/modules/
/bin/cp -raf subversion/mod_dav_svn/.libs/mod_dav_svn.so /opt/apache/modules/

echo -e "33[1;36m整合apache和subversion33[0m"
sed -i 's@LoadModule rewrite_module modules/mod_rewrite.so@LoadModule rewrite_module modules/mod_rewrite.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so@g' /opt/apache/conf/httpd.conf
cat >> /opt/apache/conf/httpd.conf << EOF

# Subversion default settings
Include conf/extra/httpd-svn.conf
EOF

cat > /opt/apache/conf/extra/httpd-svn.conf << EOF
<Location /leishen>
DAV svn
SVNListParentPath On
SVNParentPath /data/subversion
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /opt/subversion/conf/passwdfile
AuthzSVNAccessFile /opt/subversion/conf/accessfile
Require valid-user
</Location>
EOF

mkdir -p /opt/subversion/conf

##创建账户配置文件,因为是第一次创建,passwdfile文件原本不存在所以需要加-c参数,日后需要在passwdfile中追加第二个用户,去掉-c参数即可
echo -e "33[1;36m创建第一个用户 USER:jinps PASS:jinsppasswd33[0m"
/opt/apache/bin/htpasswd -bc /opt/subversion/conf/passwdfile jinsp jinsppasswd

echo -e "33[1;36m创建权限树配置文件33[0m"
cat > /opt/subversion/conf/accessfile << EOF
[groups]
manager = yunfy
ops = jinsp,bxjg

[yunwei:/]
@manager = rw
@ops = rw
* =

[yunwei:/H05]
@manager = rw
@ops = rw
* =
EOF

echo -e "33[1;36m新增SVN仓库33[0m"
mkdir -p /data/subversion
cd /data/subversion
/opt/subversion/bin/svnadmin create yunwei

echo -e "33[1;36m启动apache33[0m"
/opt/apache/bin/apachectl restart

echo -e "33[1;36m测试使用http访问svn33[0m"
echo -e "33[1;32mhttp://本机公网IP/leishen/yunwei/H0533[0m"

原文地址:https://www.cnblogs.com/fjping0606/p/7581093.html