Apache2 + Subversion + SSL

原文地址:[url]http://ubuntuforums.org/showthread.php?t=51753[/url]

根据原文在ubuntu8.04下安装svn+ssl成功,原文中的某些命令对最新的apache2已经无法使用,故在翻译中替换成最新命令。

1.安装apache2

sudo apt-get install apache2

2.安装svn

sudo apt-get install subversion

3.在apache中使用svn需要安装libapache2-svn

sudo apt-get install libapache2-svn

4.现在最好重启一下apache

sudo /etc/init.d/apache2 restart

5.如果不需要SSL支持的话请直接跳到第12步(dav_svn.conf配置).
需要SSL的话执行以下命令:

sudo a2enmod ssl

6.修改文件: /etc/apache2/ports.conf

sudo gedit /etc/apache2/ports.conf

如果只需要SSL的话,将“Listen 80”改为“Listen 443”,删除其它内容

7.新建证书

sudo apt-get install ssl-cert

sudo mkdir /etc/apache2/ssl

sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

8.新建SSL配置文件

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/myown-ssl

9.编辑新生成的文件myown-ssl

sudo gedit /etc/apache2/sites-available/myown-ssl

将代码

NameVirtualHost *

变为:

NameVirtualHost *:443

并将代码:

<VirtualHost *>

变为:

<VirtualHost *:443>

在标记 </VirtualHost>前添加如下代码:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM

10.启用新的配置文件

sudo a2ensite myown-ssl

11.重启Apache

sudo /etc/init.d/apache2 restart

12.按照文件中的操作说明修改dav_svn配置文件

sudo gedit /etc/apache2/mods-available/dav_svn.conf

以下是我修改后的文件:
# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.

# <Location URL> ... </Location>
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/# Note, a literal /svn should NOT exist in your document root.
<Location /svn>
# Uncomment this to enable the repository
DAV svn

# Set this to the path to your repository
SVNPath /srv/svn
# Alternatively, use SVNParentPath if you have multiple repositories under
# under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
# You need either SVNPath and SVNParentPath, but not both.
#SVNParentPath /var/lib/svn


# Access control is done at 3 levels: (1) Apache authentication, via
# any of several methods. A "Basic Auth" section is commented out
# below. (2) Apache <Limit> and <LimitExcept>, also commented out
# below. (3) mod_authz_svn is a svn-specific authorization module
# which offers fine-grained read/write access control for paths
# within a repository. (The first two layers are coarse-grained; you
# can only enable/disable access to an entire repository.) Note that
# mod_authz_svn is noticeably slower than the other two layers, so if
# you don't need the fine-grained control, don't configure it.

# Basic Authentication is repository-wide. It is not secure unless
# you are using https. See the 'htpasswd' command to create and
# manage the password file - and the documentation for the
# 'auth_basic' and 'authn_file' modules, which you will need for this
# (enable them with 'a2enmod').
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd

# To enable authorization via mod_authz_svn
#AuthzSVNAccessFile /etc/apache2/dav_svn.authz

# The following three lines allow anonymous read, but make
# committers authenticate themselves. It requires the 'authz_user'
# module (enable it with 'a2enmod').
#<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
#</LimitExcept>
</Location>

13.重启apache

sudo /etc/init.d/apache2 restart

14.创建SVN文件夹并授权

sudo svnadmin create /srv/svn

sudo chown -R www-data:www-data /srv/svn

sudo chmod -R g+ws /srv/svn

15.创建用户帐号文件(将svnuser换成对应的要创建的svn用户名,第一次添加用户需先创建文件,所以有参数-c,以后添加用户需要去掉参数-c)

sudo htpasswd -c /etc/apache2/dav_svn.passwd svnuser

(会提示你输入密码)

16.测试SVN

svn import .bashrc https://localhost/svn/testfile -mlogentry

That is all!!!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值