`
lz1130
  • 浏览: 408123 次
  • 性别: Icon_minigender_1
  • 来自: 福建
社区版块
存档分类
最新评论

nginx subversion apache 安装配置

阅读更多
由于nginx现在暂时不支持subversion,而web服务器又选择了nginx,所以只能安装apache集成subversion,然后通过nginx proxy给apache来实现nginx的svn

这里用的服务器版本是:ubuntu server 8.04 32bit
并且已经认为你安装了nginx

nginx的安装可以看另一篇博客nginx php 安装与配置


Apache安装
sudo apt-get install apache2
sudo apt-get install apache2-utils


Subversio与libapache2-svn安装
sudo apt-get install subversion subversion-tools libapache2-svn


把svn模块添加到/etc/apache2/mods-enabled中
cd /etc/apache2/mods-enabled
ln -s ../mods-available/dav_fs.* ./
ln -s ../mods-available/dav_svn.* ./
ln -s ../mods-available/dav.load ./


建立svn文件库
sudo mkdir /home/workhome/svn
sudo svnadmin create /home/workhome/svn/test
ls  -l /home/workhome/svn/test
看到以下文件则成功
-rw-r--r-- 1 root root  229 Oct  7 14:22 README.txt
drwxr-xr-x 2 root root 4096 Oct  7 14:22 conf
drwxr-sr-x 6 root root 4096 Oct  7 14:22 db
-r--r--r-- 1 root root    2 Oct  7 14:22 format
drwxr-xr-x 2 root root 4096 Oct  7 14:22 hooks
drwxr-xr-x 2 root root 4096 Oct  7 14:22 locks


权限设置
sudo chown -R ftp:ftp /home/workhome/svn
sudo chown -R www-data /home/workhome/svn/test


配置svn的VirtualHost
sudo mv /etc/apache2/sites-available/default /etc/apache2/sites-available/svn.sends.cc.conf
cd /etc/apache2/sites-enabled/
sudo rm default
sudo ln -s /etc/apache2/sites-available/svn.sends.cc.conf ./
sudo vi svn.sends.cc.conf


配置文件如下:

NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@sends.cc

<Location />

  # Uncomment this to enable the repository
  DAV svn

  # Set this to the path to your repository
  #SVNPath /home/workhome/svn/test
  # 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 /home/workhome/svn

#---------------------
  SVNListParentPath On
  SVNAutoversioning On
#---------------------

  # 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 Of SendsLab"
  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>


        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/svn.sends.cc.error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/svn.sends.cc.access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/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
    </Directory>

</VirtualHost>


建立密码文件dav_svn.passwd
sudo htpasswd -c /etc/apache2/dav_svn.passwd root
建立其他用户及修改密码
sudo htpasswd  /etc/apache2/dav_svn.passwd isends


建立授权文件dav_svn.authz
sudo cp /home/workhome/svn/test/conf/authz /etc/apache2/dav_svn.authz
内容参考如下:
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
sendsadmin = root
sendstest = sendstest
other = isends

[/]
@sendsadmin = rw
@sendstest = r
* =

[test:/]
@sendsadmin = rw
@sendstest = rw
* =



更改apache端口
sudo vi /etc/apache2/ports.conf
这里改成20080
ps:别忘了防火墙打开端口


Nginx配置(我nginx的虚机主机都在vhost下)
sudo vi /usr/local/web/nginx636/conf/vhost/svn.sends.cc.conf
加入以下:
    server {
        listen       80;
        server_name  svn.sends.cc;
        access_log   /var/log/nginx/svn.sends.cc.access.log  main;
        root  /home/workhome/svn;

         location / {
                   proxy_set_header Host $host;
                   proxy_set_header X-Real-IP $remote_addr;
                   proxy_set_header X-Forwarded-Proto https;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_pass http://127.0.0.1:20080;
         }
    }


svn客户端与使用
svn客户端TortoiseSVN,使用很简单,安装后在任意盘符建立一个目录,右键单击目录选择“SVN 检出”。输入svn文件库地址(如http://svn.sends.cc/test)、账号、密码便可迁出项目。
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics