apache + subversion for linux安裝 SVN是管理工程本版的必備工具,相對vss以及其前身cvs來說都有著無與倫比的優勢 以下是apache+subversion服務端安裝步驟: 一、準備好安裝包: ①apr-1.3.6.tar.gz :http://apr.apache.org/ ②apr-util-1.3.8.tar.gz ③subversion-1.6.3.tar.gz : http://subversion.tigris.org/ ④subversion-deps-1.6.3.tar.gz ⑤httpd-2.2.9.tar.gz :http://httpd.apache.org/ 注意:apach的版本 與 subversion版本的相容問題,官網都有介紹的 二、開始安裝:把以上安裝包上傳至/usr/local目錄,cd /usr/local 進入該目錄 1、安裝apr tar zxvf apr-1.3.6.tar.gz #解壓包 cd apr-1.3.6 ./configure make make install 2、安裝apr-util tar zxvf apr-util-1.3.8.tar.gz cd apr-util-1.3.8 ./configure --with-apr=/usr/local/apr make make install 3、安裝 apache tar zxvf httpd-2.2.9.tar.gz cd httpd-2.2.9 ./configure --prefix=/usr/local/apache2.2.9 --enable-dav --enable-so --enable-maintainer-mode --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config #--prefix表示把apache安裝在指定目錄 make make install 4、安裝subversion tar zxvf subversion-1.6.3.tar.gz tar zxvf subversion-deps-1.6.3.tar.gz cd subversion-1.6.3 ./configure --prefix=/opt/svn --with-apxs=/usr/local/apache2.2.9/bin/apxs --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr make make install 至此,安裝基本完畢,再配置下就可以使用了 注意:因為這些安裝包需要gcc編譯,所以要確保linux上裝有gcc程式,否則是沒辦法進行安裝的 三、在apache中配置SVN vi /usr/local/apache2.2.9/conf/httpd.conf ① 如果你看到如下兩句,說明安裝是成功的 LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so 如果有下面一句就用#注釋掉 #LoadModule foo_module modules/mod_foo.so ② 定義apache訪問svn配置: <Location /svn> DAV svn # SVNPath /opt/svndata SVNParentPath /opt/svndata AuthzSVNAccessFile /opt/svn/conf/authz.conf AuthType Basic AuthName "Subversion repository" AuthUserFile /opt/svn/conf/passwd.conf Require valid-user </Location> 四、配置svn ①建立svn版本庫目錄 mkdir -p /opt/svndata/repos #可以多建版本庫目錄 ②建立svn版本庫 svnadmin create /opt/svndata/repos mkdir -p /opt/svndata/repos #可以多建版本庫 ③建立本地存取控制檔案 /usr/local/apache2.2.9/bin/htpasswd -c /opt/svn/conf/passwd.conf username 然後輸入密碼即可,預設是MD5加密的 /usr/local/apache2.2.9/bin/htpasswd /opt/svn/conf/passwd.conf username1 #追加使用者 ④建立本地項目控制檔案 touch /opt/svn/conf/authz.conf 本例authz.conf內容為: [groups] #<groupname1>=<username1>,<username2> admin=username #[<versionLib>:projectName/directory] #@<groupsname>=<authorities> #<username>=<authorities> [/] @admin = rw #指定使用者群組成員可以讀寫根目錄所有應用 [repos:/abc/aaa] username1= rw #指定使用者username1可以讀寫:/abc/aaa目錄的檔案 至此,整個安裝過程完成了! 五、測試連接 ① 啟動apache /usr/local/apache2.2.9/bin/apachectl start ② 開啟瀏覽器,輸入http://192.168.1.107/svn/repos #本例伺服器ip是192.168.1.107 使用剛才建立的許可權使用者名稱與密碼登入即可訪問 注意:在你上傳檔案的時候可能會有如下許可權不足的提示 Permission denied svn: Commit failed (details follow): svn: Can't create directory '/opt/svndata/repos/db/transactions/0-1.txn': Permission denied 這是因為apache線上程使用者沒有許可權訪問svn的倉庫,兩者分別屬於不同的使用者者 本例apache屬於daemon擁有者,而svn倉庫屬於svn擁有者 解決方案: chown -R daemon /opt/svndata/repos chmod -R 755 /opt/svndata/repos 重啟下apache: /usr/local/apache2.2.9/bin/apachectl stop /usr/local/apache2.2.9/bin/apachectl start 本例是通過Eclipse的svn外掛程式用戶端測試的,上傳下載完全正常!伺服器系統是 linux Fedora 7。