nginx subversion apache 安裝配置

因爲nginx如今暫時不支持subversion,而web服務器又選擇了nginx,因此只能安裝apache集成subversion,而後經過nginx proxy給apache來實現nginx的svn nginx

 

sudo apt-get install apache2
sudo apt-get install apache2-utils

 

Subversio與libapache2-svn安裝 web

 

sudo apt-get install subversion subversion-tools libapache2-svn

 

把svn模塊添加到/etc/apache2/mods-enabled中 apache

 

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

 

權限設置less

 

sudo chown -R ftp:ftp /home/workhome/svn
sudo chown -R www-data /home/workhome/svn/test

 

配置svn的VirtualHost ide

 

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

 

配置文件以下:svn

 

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 ui

 

sudo htpasswd -c /etc/apache2/dav_svn.passwd root
創建其餘用戶及修改密碼
sudo htpasswd  /etc/apache2/dav_svn.passwd isends

創建受權文件dav_svn.authz this

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端口 spa

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)、帳號、密碼即可遷出項目。
相關文章
相關標籤/搜索