ubuntu8.04 成功源代碼安裝 subversion1.5.0,apache2.2.9

apache源代碼壓縮包 httpd-2.2.9.tar.bz2 svn源代碼壓縮包 subversion-deps-1.5.0.tar.bz2 subversion-1.5.0.tar.gz

安裝apache 解壓httpd-2.2.9.tar.bz2,進入解壓後的文件夾,執行configure,命令如下 ./configure --enable-dav --enable-so --prefix=/opt/apache2, 其中,--enable-dav允許Apache提供DAV協議支持;--enable-so允許運行時加載DSO模塊,前兩個參數是必須要加的,--prefix 是安裝的位置如果configure通過,接着執行 make && make install ,數分鐘後就完事了,通過 /opt/apache2/bin/apachectl -k start 來啓動,在瀏覽器中訪問127.0.0.1,如果出現 It's Works!,那麼說明安裝成功。

安裝subversion 分別解壓subversion-deps-1.5.0.tar.bz2和subversion-1.5.0.tar.gz,解壓後他們都在subversion-1.5.0這個文件夾下,然後執行configure,命令如下 ./configure --with-apxs=/opt/apache2/bin/apxs --with-apr=/opt/apache2 --with-apr-util=/opt/apache2 --prefix=/opt/subversion-1.5.0 其中,--with-apxs 用於生成apache httpd的mod_dav_svn和mod_authz_svn模塊;--with-apr 和 --with-apr-util=參數指向 Apache 的安裝根目錄,而不是使用缺省的 SVN 安裝包中自帶的 apr ,否則如果你安裝的 Apache 版本不同有可能導致 APR 庫不匹配,出現類似 Can't set position pointer in file '/svn/test/db/revs/1': Invalid argument 的錯誤,--prefix 是安裝的位置。注意,在configure的時候可能回出現 configure: error: no XML parser was found: expat or libxml 2.x required和configure: error: We require OpenSSL; try --with-openssl這兩個錯誤分別通過下面的apt-get來安裝確實的庫, apt-get install libxml2 libxml2-dev  expat apt-get install openSSL libssl-dev 也可以在configure前先檢查一下本地是否已經存在上述所需要的lib,dpkg -l | grep libxml2和dpkg -l | grep openssl configure通過後進行make,似乎在make的時候會出現一個Error,信息如下 /usr/bin/ld: cannot find -lexpat,好像找不到libexpat.so這個庫文件,但是/usr/lib下有/usr/lib/libexpat.so.1,於是做了一個link,命令如下 ln -s  /usr/lib/libexpat.so.1 /usr/lib/libexpat.so 再執行make,就通過了,使用make install安裝。

創建的Subversion的版本庫假設我們把版本庫建立在/opt/svnroot 目錄下,那麼在/opt/svnroot目錄下執行mkdir repository新建版本庫文件夾,通過svnadmin create repository/test命令可創建名爲test的版本庫。若創建成功,則subversion的安裝便已成功完成。使用mkdir –p import/{trunk,branches,tags} 命令在/opt/svnroot目錄下建立一個名爲import的新文件夾,包含trunk、branches、tags 三個子目錄。下面這條語句將把路徑/opt/svnroot/import下的目錄和文件導入到你創建的Subversion 倉庫中去,提交後的修訂版爲1。 svn import /opt/svnroot/import file:///opt/svnroot/repository/test –m "Init repository" 這裏/opt/svnroot/import可以使用相對路徑,但file:///opt/svnroot/repository/test必須以絕對路徑表示。

使用htpasswd 生成身份認證文件,具體命令如下: htpasswd -m  -c /opt/svnroot/repository/pwdfile user1 (-c 是生成pwdfile文件,如果文件存在就不用帶 -c 參數) htpasswd -m  /opt/svnroot/repository/pwdfile user2 htpasswd -m  /opt/svnroot/repository/pwdfile user3 這樣就創建了3個用戶

創建授權文件授權文件用於確定每個用戶對特定目錄的操作權限,格式可參考版本庫下的conf/authz(conf目錄下的authz文件用於svnserve的授權,與我們所使用的mod_authz_svn的授權文件具有相同的格式)。因而我們可以直接把conf下的authz複製到我們想要的/opt/svnroot/repository目錄下,然後加以修改。修改後的文件大概是如下: [groups] g_pm=user1 g_dev=user2 g_dev=user3

[test:/] @g_pm=rw @g_dev=r

[test:/trunk] @g_pm=rw @g_dev=r

[test:/branches] @g_pm=rw @g_dev=rw

[test:/tags] @g_pm=rw @g_dev=rw

修改目錄的owner及權限 chown -R apache:apache /opt/svnroot chmod 700 /opt/svnroot chmod -R 700 /opt/svnroot/repository

修改apache的httpd.conf文件修改User和Group都爲apache

在文件的最後加上 <location /svn>         DAV svn         SVNParentPath /opt/svnroot/repository/         AuthType Basic         AuthName "Subversion Repository"         AuthUserFile /opt/svnroot/repository/pwdfile         AuthzSVNAccessFile /opt/svnroot/repository/authz         Satisfy Any         Require valid-user </Location> 其中/svn表示一個url的模式,匹配形如http://host/svn的url;SVNParentPath 指定的目錄下的所有項目都被subversion 認爲是合法的版本庫;AuthzSVNAccessFile爲授權文件 ;AuthType 則制定了客戶端身份認證機制,Basic表示http基本認證機制;AuthUserFile就是先前創建的密碼文件;Satisfy Any 和Require valid-user告訴apache所有用戶先使用匿名方式訪問版本庫,只有當訪問控制策略要求一個真實的用戶名時,apache纔會對客戶端進行身份驗證,這是使用得最多的一種授權方式。

至此,subverion加apache2 安裝配置就完成了!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章