svn1.8.8+apache2.4.7+openssl1.0.1g搭建svn服务器

1. 下载和编译以下软件

######################################## tar zxvf openssl-1.0.1g.tar.gz cd openssl-1.0.1g ./configure --prefix=/usr/local/openssl -fPIC make make install cd .. ######################################## tar zxvf pcre-8.35.tar.gz cd pcre-8.35 ./configure --prefix=/usr/local/pcre make make install cd .. ######################################## tar zxvf apr-1.5.1.tar.gz cd apr-1.5.1 ./configure --prefix=/usr/local/apr make make install cd .. ######################################## tar zxvf apr-util-1.5.3.tar.gz cd apr-util-1.5.3 ./configure --prefix=/usr/local/apr-util make make install cd ..
2. 编译安装httpd

#########################################
tar zxvf httpd-2.4.9.tar.gz
cd httpd-2.4.9
./configure --prefix=/usr/local/apache --enable-dav --enable-so --enable-deflate=shared --enable-ssl --enable-expires=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support --with-mpm=prefork --enable-cache --enable-file-cache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl
make
make install
cd ..
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
编辑/etc/init.d/httpd
在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.
chkconfig --add /etc/init.d/httpd
service httpd start
3.编译和安装subversion

tar zxvf subversion-1.8.8.tar.gz
cd subversion-1.8.8
#make clean
./configure --prefix=/usr/local/subversion --with-apxs=/usr/local/apache/bin/apxs --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-sqlite=/usr/local/sqlite --with-openssl
make
make install
cd ..

\cp -f subversion-1.8.8/subversion/mod_dav_svn/.libs/mod_dav_svn.so /usr/local/apache/modules/
\cp -f subversion-1.8.8/subversion/mod_authz_svn/.libs/mod_authz_svn.so /usr/local/apache/modules/
echo "PATH=$PATH/:/usr/local/subversion/bin" >> /etc/profile
source /etc/profile

4.修 httpd.conf

vim /usr/local/apache/conf/httpd.conf

Include conf/extra/httpd-ssl.conf #将前面的#号去掉

.......

#需要有以下模块支持,这是在编译httpd前加相关参数生成的

LoadModule ssl_module modules/mod_ssl.so

LoadModule dav_module modules/mod_dav.so

LoadModule dav_lock_module modules/mod_dav_lock.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

添加以下代码:

<Location /svn>
        DAV svn
        SVNParentPath /data/svn
        AuthType Basic
        AuthName "PleaseLogin"
        AuthUserFile /usr/local/apache/svn-passwd
        AuthzSVNAccessFile /usr/local/apache/svn-access
        Require valid-user
        SSLRequireSSL
</Location>

由于在httpd.conf中增加了SSLRequireSSL,则只支持https访问。

5.用以下三步生成证书

1) 生成密钥server.key

openssl genrsa 1024 > server.key

2) 生成证书请求文件server.csr.crt

openssl req -new -key server.key > server.csr.crt

3) 根据密钥及证书请求文件生成证书server.crt

openssl req -x509 -days 365 -key server.key -in server.csr.crt > server.crt

4)检查apache配置文件语法

../bin/apachectl -t


6.创建svn用户及密码文件

/usr/local/apache/bin/htpasswd -cm /usr/local/svn/svn-passwd aa

/usr/local/apache/bin/htpasswd -m /usr/local/svn/svn-passwd bb

/usr/local/apache/bin/htpasswd -m /usr/local/svn/svn-passwd cc


7. 创建访问控制文件,设置用户访问权限

vim /usr/local/svn/svn-access

[groups]

staff = aa, bb, cc


[/project-1]

@staff = rw


[/project-2]

@staff = rw


8.创建数据仓库

mkdir /data/svn

svnadmin create /data/svn/project-1

chmod -R 755 /data/svn/project-1

chown -R svn:svn /data/svn/project-1

9.重启httpd
service httpd restart

你可能感兴趣的:(SVN)