sudo apt-get install subversion libapache2-svn
sudo svnadmin create /svn
$ sudo chown -R root:subversion svn
$ sudo chmod -R g+rws svn
sudo gedit /etc/apache2/mods-enabled/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
SVNParentPath /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 /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
AuthUserFile /svn/svn1/conf/passwd
# To enable authorization via mod_authz_svn
# AuthzSVNAccessFile /etc/apache2/dav_svn.authz
# AuthzSVNAccessFile /svn/svn1/conf/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>
The DAV line needs to be uncommented to enable the dav module
# Uncomment this to enable the repository,
DAV svn
The SVNPath line should be set to the same place your created the repository with the svnadmin command.
# Set this to the path to your repository
SVNPath /svn
The next section will let you turn on authentication. This is just basic authentication, so don't consider it extremely secure. The password file will be located where the AuthUserFile setting sets it to… probably best to leave it at the default.
To create a user on the repository use, the following command:# Uncomment the following 3 lines to enable Basic Authentication
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
wget http://librarian.launchpad.net/6917265/files.tar
tar xvf files.tar
然后安装Apache2 deb源代码及相关编译依赖包,然后编译安装apache2:
sudo apt-get build-dep apache2 sudo apt-get source -d apache2 dpkg-source -x apache2_2.2.3-3.2build1.dsc cd apache2-2.2.3 fakeroot debian/rules binary(如果没有安装fakeroot,请先安装) sudo dpkg -i ../*.deb(您也可以选择性的安装您需要的Apache2 deb包)
如果您不愿自己编译,可以到这里下载编译好的Apache2 Deb包。
这样安装的apache2包含完整的工具,下面我们来配置Apache2 ssl支持:
先生成站点证书:
sudo apache2-ssl-certificate -days 365
接着启用Apache2 的ssl模块:
sudo a2enmod ssl
增加ssl端口443监听:
echo "Listen 443" | sudo tee -a /etc/apache2/ports.conf
创建并启用ssl站点:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl sudo gedit /etc/apache2/sites-available/ssl
修改其内容,设定对应端口,启用ssl,指定站点证书文件位置等,修改后类似如下:
NameVirtualHost *:443 *:443> ServerAdmin webmaster@localhost SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.pem DocumentRoot /var/www/ /> Options FollowSymLinks AllowOverride None > /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place # Commented out for Ubuntu #RedirectMatch ^/$ /apache2-default/ > ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ "/usr/lib/cgi-bin"> AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all > ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 > >
修改default站点配置,指定其端口为80:
sudo gedit /etc/apache2/sites-available/default
将其内容前面两行修改为:
NameVirtualHost *:80 80>
然后启用上面配置的ssl站点:
sudo a2ensite ssl
启动Apache2:
sudo /etc/init.d/apache2 start
大功告成,现在您可以使用https://127.0.0.1测试服务是否正常启动,也可以使用以下命令查看apache ssl服务是否启动:
netstat -na|grep :443
正常的话您应该可以看到如下的输入:
tcp6 0 0 :::443 :::* LISTEN建立控制用户访问权限的文件svn-access-filename