-
- 安装zlib和openssl
wget http://zlib.net/zlib-1.2.8.tar.gz tar zxf zlib-1.2.8.tar.gz -C /usr/local/src/ cd /usr/local/src/zlib-1.2.8/ CFLAGS="-fPIC -O3" ./configure --shared --64 make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install chcon -R -u system_u /usr/local/lib/libz.so* cd wget https://www.openssl.org/source/openssl-1.0.2e.tar.gz tar zxf openssl-1.0.2e.tar.gz -C /usr/local/src/ cd /usr/local/src/openssl-1.0.2e/ CFLAGS="-fPIC -O3" ./config --prefix=/usr/local/openssl shared threads zlib make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install ln -s /usr/local/openssl/lib/lib*.so* /usr/local/lib/ ln -s /usr/local/openssl/lib/pkgconfig/* /usr/local/lib/pkgconfig/ ln -s /usr/local/openssl/include/* /usr/local/include/ echo "/usr/local/lib" > /etc/ld.so.conf.d/comp.conf echo 'export PATH=/usr/local/openssl/bin/:$PATH' > /etc/profile.d/openssl.sh source /etc/profile.d/openssl.sh
- 安装zlib和openssl
-
- 安装Apache,所有源码包都可以在Apache官网上找到下载连接
建立Apache进程用户groupadd -g 222 apache useradd -u 222 -g apache -s /sbin/nologin -d /var/www/ -M apache mkdir -p /var/www chown -R apache:apache /var/www/
安装apr和apr-util依赖包
cd wget http://www.us.apache.org/dist/apr/apr-1.5.2.tar.gz tar zxf apr-1.5.2.tar.gz -C /usr/local/src/ cd /usr/local/src/apr-1.5.2/ CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/apr make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install cd wget http://www.us.apache.org/dist/apr/apr-util-1.5.4.tar.gz tar zxf apr-util-1.5.4.tar.gz -C /usr/local/src/ cd /usr/local/src/apr-util-1.5.4/ CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/apr/ --with-apr=/usr/local/apr/ --with-openssl=/usr/local/openssl/ make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
安装Apache
cd wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.16.tar.gz tar zxf httpd-2.4.16.tar.gz -C /usr/local/src/ cd /usr/local/src/httpd-2.4.16/ CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-mime-magic --enable-ssl --enable-session --enable-session-cookie --enable-proxy --enable-cache --enable-cache-disk --enable-cache-socache --enable-buffer --enable-dav --enable-cgi --with-z=/usr/local/lib --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr/ --with-ssl=/usr/local/openssl/ --with-mpm=prefork make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --reload
安装sqllite、sasl、SVN
wget http://www.sqlite.org/2015/sqlite-autoconf-3081100.tar.gz tar zxf sqlite-autoconf-3081100.tar.gz -C /usr/local/src/ cd /usr/local/src/sqlite-autoconf-3081100/ CFLAGS="-fPIC -O3" ./configure make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install cd wget ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz tar zxf cyrus-sasl-2.1.26.tar.gz -C /usr/local/src/ cd /usr/local/src/cyrus-sasl-2.1.26/ CFLAGS="-fPIC -O3" ./configure --prefix=/usr/local/sasl --enable-sql --with-openssl=/usr/local/openssl/ --with-sqlite3=/usr/local/ make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install cd wget http://mirrors.hust.edu.cn/apache/subversion/subversion-1.8.13.tar.gz tar zxf subversion-1.8.13.tar.gz -C /usr/local/src/ cd /usr/local/src/subversion-1.8.13/ CFLAGS="-fPIC -O3" ./configure --enable-optimize --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-apxs=/usr/local/apache/bin/apxs --with-openssl=/usr/local/openssl/ --with-zlib=/usr/local/lib --with-sasl=/usr/local/sasl/ make -j `cat /proc/cpuinfo | grep processor | wc -l`;make install
配置添加Apache的SVN扩展项
cp /usr/local/libexec/mod_authz_svn.so /usr/local/apache/modules/ cp /usr/local/libexec/mod_dav_svn.so /usr/local/apache/modules/ vim /usr/local/apache/conf/httpd.conf
去掉前面的注释
LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so
添加模块加载项
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
添加SVN配置文件
Include conf/extra/httpd-svn.conf
创建并编辑SVN配置文件
echo "#SVN CONF FILE" > /usr/local/apache/conf/extra/httpd-svn.conf
设置URL访问路径
echo '<Location /svn>' >> /usr/local/apache/conf/extra/httpd-svn.conf echo ' DAV svn' >> /usr/local/apache/conf/extra/httpd-svn.conf
SVN根目录设置
echo ' SVNParentPath /var/www/svn/data' >> /usr/local/apache/conf/extra/httpd-svn.conf echo ' SVNListParentPath On' >> /usr/local/apache/conf/extra/httpd-svn.conf echo ' SVNAutoversioning On' >> /usr/local/apache/conf/extra/httpd-svn.conf echo ' SVNReposName "svn"' >> /usr/local/apache/conf/extra/httpd-svn.conf
目录分组权限文件
echo ' AuthzSVNAccessFile /var/www/svn/conf/authz.conf' >> /usr/local/apache/conf/extra/httpd-svn.conf
验证类型
echo ' AuthType Basic' >> /usr/local/apache/conf/extra/httpd-svn.conf
提示信息
echo ' AuthName "Subversion repository"' >> /usr/local/apache/conf/extra/httpd-svn.conf
密码验证文件
echo ' AuthUserFile /var/www/svn/conf/passwd.conf' >> /usr/local/apache/conf/extra/httpd-svn.conf echo ' Require valid-user' >> /usr/local/apache/conf/extra/httpd-svn.conf echo '</Location>' >> /usr/local/apache/conf/extra/httpd-svn.conf cat /usr/local/apache/conf/extra/httpd-svn.conf
- 创建SVN仓库及配置
创建SVN仓库mkdir -p /var/www/svn/data/repos svnadmin create /var/www/svn/data/repos chown -R apache:apache /var/www/svn/data/ mkdir -p /var/www/svn/conf
创建密码验证文件文件并添加用户admin
/usr/local/apache/bin/htpasswd -cm /var/www/svn/conf/passwd.conf admin
后续添加用户使用
/usr/local/apache/bin/htpasswd /var/www/svn/conf/passwd.conf username
创建目录分组权限文件
echo '##This file is an authorization file for svnserve.' > /var/www/svn/conf/authz.conf
群组设置
echo '[groups]' >> /var/www/svn/conf/authz.conf echo '#<groupname1>=<username1>,<username2>' >> /var/www/svn/conf/authz.conf echo 'admin = admin' >> /var/www/svn/conf/authz.conf echo '' >> /var/www/svn/conf/authz.conf echo '#[<versionLib>:projectName/directory]' >> /var/www/svn/conf/authz.conf echo '#@<groupsname>=<authorities>' >> /var/www/svn/conf/authz.conf echo '#<username>=<authorities>' >> /var/www/svn/conf/authz.conf echo '' >> /var/www/svn/conf/authz.conf
在所有仓库的根目录下
echo '[/]' >> /var/www/svn/conf/authz.conf
admin组具有读写权限
echo '@admin = rw ' >> /var/www/svn/conf/authz.conf
所有用户具有读权限
echo '* = r' >> /var/www/svn/conf/authz.conf echo '' >> /var/www/svn/conf/authz.conf
指定user1具有仓库repos的读写权限
echo '[repos:/]' >> /var/www/svn/conf/authz.conf echo 'user1 = rw' >> /var/www/svn/conf/authz.conf cat /var/www/svn/conf/authz.conf
- 目录分组权限文件相关项说明
[groups] 表示群组设置
admin = admin 表示admin组里的成员有admin用户,多用户用英文,分隔
[/] 表示在所有仓库的根目录下
@admin = rw admin组具有读写权限
* = r 所有用户具有读权限
[repos:/] 表示在repos仓库下
user1 = rw user1用户具有读写权限
- 目录分组权限文件相关项说明
- 启动Apache
/usr/local/apache/bin/apachectl start
验证模块加载
/usr/local/apache/bin/apachectl -M | grep svn
- 浏览器访问
- 使用TortoiseSVN工具
创建文件测试提交
验证OK
- 安装Apache,所有源码包都可以在Apache官网上找到下载连接
至此SVN服务已搭建完毕,我们也可以给Apache添加SSL证书(或申请或使用openssl创建)以实现SSL加密访问,这点我会在之后文章中配合Apache虚拟主机一起讲解。
牛逼