Linux 安裝SVN 整合Apache + 許可權控制

來源:互聯網
上載者:User

一:相關版本
subversion在安裝的時候,要求相關軟體的版本一致,而不是說軟體版本最新就最好.下面是我安裝的相關版本.
httpd-2.2.3.tar.gz
subversion-deps-1.4.0.tar.gz
subversion-1.4.0.tar.gz

二:安裝準備
# mkdir /subversion
# cp httpd-2.2.3.tar.gz /subversion/
# cp subversion-deps-1.4.0.tar.gz /subversion/
# cp subversion-1.4.0.tar.gz /subversion/
# cd /subversion/
# tar zxvf httpd-2.2.3.tar.gz
# tar zxvf subversion-deps-1.4.0.tar.gz
# tar zxvf subversion-1.4.0.tar.gz

到這一步,如果是32位的linux系統,可以直接安裝httpd了,如果地64位的linux,需要進行以下操作,進行重新編譯:
1、刪除安裝目錄下的configure檔案,在我的環境中是httpd-2.2.6/configure
2、刪除“httpd-2.26/srclib/apr-util/configure”
3、通過以下命令重建編譯檔案(以下命令在http-2.26/目錄下運行)。
#./buildconf
通過以上重建編譯檔案,現在可以擁有64位的apr-util了

三:httpd的安裝.
# cd /subversion/httpd-2.2.3
# ./configure --enable-dav --enable-so --prefix=/usr/local/apache2/ --enable-maintainer-mode 

(注意以上命令,參數不能隨意減少,否則有可能出現一些未知的錯誤
 如果是上面經過重建編譯檔案的64位Linux,使用如下命令:
#  ./configure --enable-dav --enable-so --prefix=/usr/local/apache2/ --enable-maintainer-mode --with-expat=builtin

# make
# make install
# cd /usr/local/apache2/bin/
# ./apachectl start   (該命令可能會出現類似 Could not reliably determine the server's fully qualified domain name, using 192.168.0.71 for ServerName的錯誤,不用管它,服務實際上已經啟動了 停止和重啟也一樣)
這個時候,開啟瀏覽器,輸入http://localhost/,如果瀏覽器出現It Works,則說明httpd安裝成功了.

四:subversion的安裝
# cd /subversion/subversion-1.4.0
# ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/ --with-apr-util=/usr/local/apache2/ --prefix=/usr/local/subversion --with-ssl --with-zlib --enable-maintianer-mode
# make && make install


 如果出現錯誤:make: *** [subversion/libsvn_ra_dav/libsvn_ra_dav-1.la] Error 1
 解決方案 在neon/src/Makefie 的 CFLAGS中增加 -fPIC選項 一定要加到最前面,例如 CFLAGS = -fPIC -g -O2
 重新make

五:建立和匯入版本庫
[root@localhost subversion-1.4.0]# cd /usr/local/subversion/bin/
[root@localhost bin]# mkdir /repository
[root@localhost bin]# ./svnadmin create --fs-type fsfs /repository/test
[root@localhost bin]# ls /repository/test/  
//如果ls /repository/test/ 出現了下面的內容,就說明subversion安裝成功了.
conf   dav   db   format   hooks   locks   README.txt

匯入版本庫
[root@localhost bin]# ./svn import /root/src/ file:///repository/test/ -m "initial import"
//命令成功執行,會有如下的提示資訊,.
新增           /root/src/main.cpp
提交後的修訂版為 1。

六:修改目錄許可權
[root@localhost bin]# cd /repository/test/
[root@localhost test]# chmod -R 777 *

七:修改Apache的設定檔
1):開啟apache2/conf/httpd.conf檔案
2):修改httpd.conf檔案,在檔案的最後添加下面幾行
<Location /svn>
DAV svn
SVNParentPath /usr/local/subversion/repository
</Location>
3):儲存退出

上面指定的是,SVN不需要許可權,即任何匿名使用者都可以訪問、修改、提交
在實際使用當中,需要有許可權控制才行,因此,設定檔需要如下詳細配置:

進入apache2/bin目錄,建立使用者組和使用者檔案  當然也可以是在其它檔案夾,個人習慣把它放在這裡方便操作

建立使用者組檔案:
# touch authz

在authz檔案中寫入如下內容,下面代碼說明使用者組admin有lyd,zzq,mc,yhl四個使用者,admin組對[/]表示根目錄具有讀寫權限 r代表讀 w代表寫:

[groups]
admin = lyd,zzq,mc,yhl
[/]
@admin = rw

建立使用者,這裡的使用者需要在上面的使用者組裡面,才能有相應的許可權:
htpasswd -cm pwd.txt lyd   第一次建立,加上 -cm 參數,需要建立使用者檔案pwd.txt,當然你也可以用別名字或尾碼名

htpasswd  pwd.txt zzq   第二次建立,因為第一次已經建立了使用者檔案,所以只需要在使用者檔案中直接添加使用者即可

修改apache2/conf/httpd.conf檔案,在最後添加下面代碼,指定SVN的版本庫位置及剛才建立的,許可權需要使用的檔案

<Location /svn>
DAV svn
SVNParentPath /usr/local/subversion/repository/
AuthzSVNAccessFile /usr/local/apache2/bin/authz
AuthType Basic
AuthName "Subversion"
AuthUserFile /usr/local/apache2/bin/pwd.txt
Require valid-user
</Location>

八:重啟apache服務.
[root@localhost bin]# cd /usr/local/apache2/bin/
[root@localhost bin]# ./apachectl stop
[root@localhost bin]# ./apachectl start
或者直接 restart

起動SVN
/usr/local/subversion/bin/svnserve -d -r /repository

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.