nginx將svn請求轉發到apache實現svn http請求

須要安裝apache libapache2-svn模塊nginxsvn。安裝過程略過。php

記錄比較重要幾點(不按前後):html

  1. 安裝apache的svn模塊nginx

    sudo apt-get install libapache2-svn

    apahce的svn模塊,經過他實現svn權限等問題。apache

    apt-get install apache2-utils

    若是想經過htpasswd來給svn加(修改重置)密碼,就安裝apache2-utilsvim

    eg:
       htpasswd /home/svn/work/conf/passwd tb
       New password: 
       Re-type new password: 
       Updating password for user tb
  2. nginx監聽轉發給apache請求:segmentfault

    nginx 監聽請求轉發到apache的86端口(由於不能同時佔用80)svn

    vim /etc/nginx/conf.d優化

    server{ui

    listen 80;
       server_name svn.tb.com;
       location /svn/work {
           proxy_pass http://127.0.0.1:86/svn/work;
       }

    }.net

    經過上述代碼實現請求http://svn.tb.com/svn/work/時的正確響應。
     (請求此網址是nginx響應,對應下面apache響應)
  3. 設置apache監聽端口爲86,儘可能最小化安裝,減小內存。具體可看末尾視頻。
    //apache 的ports.conf ,監聽86端口
    Listen 86

  4. 初始化svn根目錄
    eg:
    /home/svn/work是經過sudo svnadmin create創建的目錄
    建立成功後目錄以下:
    drwxr-xr-x 2 root root 4096 1月 15 10:52 conf
    drwxr-sr-x 6 root root 4096 1月 15 14:52 db
    -r--r--r-- 1 root root 2 1月 15 10:50 format
    drwxr-xr-x 2 root root 4096 1月 15 10:50 hooks
    drwxr-xr-x 2 root root 4096 1月 15 10:50 locks
    -rw-r--r-- 1 root root 246 1月 15 10:50 README.txt

  5. apache配置設置-perfork

    apache2.conf添加,第一份是優化(具體參考末尾視頻)
     第二份是訪問監聽相似http://192.168.92.247:86/svn/work/的請求,
     (此網址請求爲apache響應請求,對應上面nginx請求)
       <IfModule mpm_prefork_module>
               StartServers        1
               MinSpareServers      1
               MaxSpareServers      1
               MaxClients          10
               MaxRequestsPerChild  0
       </IfModule>
           
       <Location /svn/work>
           DAV svn
           SVNPath /home/svn/work
           AuthType Basic
           AuthName "Authorization Realm"
           AuthUserFile /home/svn/work/conf/passwd
           AuthzSVNAccessFile /home/svn/work/conf/authz
           Require valid-user
       </Location>
  6. 關於svn的一些設置,比較重要的是設置權限(可參考末尾連接)

    啓動&檢測
    svnserve -d //後臺啓動
    netstat -antp |grep svnserve或者 ps -A |grep "svn" //檢測是否啓動

    將線上代碼(未版本化的文件)初始化到版本庫中
    sudo svn import /usr/share/nginx/html file:///home/svn/work -m "init"

    [sudo] password for tb250:
    正在增長 /usr/share/nginx/html/50x.html
    正在增長 /usr/share/nginx/html/index.html
    正在增長 /usr/share/nginx/html/info.php
    正在增長 /usr/share/nginx/html/mail.php

    提交後的版本爲 1。

    從版本庫中checkout一份代碼 svn_code
    sudo svn checkout file:///home/svn/work /home/tb250/svn_code

    從版本庫中再checkout另一份代碼 svn_code_2
    sudo svn checkout file:///home/svn/work /home/tb250/svn_code_2

    添加 svn add xx.php

    svn status (簡寫 svn st)
    A xx.php

    svn commit -m 'add xx.php'(簡寫 svn ci)

    更新到最新版本
    svn update 簡寫 svn up

    更新到某個版本
    svn update -r numerversion

    查看添加日誌
    svn log


寫在最後:我的整理。不足之處請各位指點

svn經常使用指令參考
nginx+svn+apache視頻
svn權限設置

相關文章
相關標籤/搜索