2011年7月4日 星期一

[Linux]架設Subversion server

準備套件
1. apr-1.4.5.tar.gz 下載地址:http://apr.apache.org/
2. apr-util-1.3.12.tar.gz
3. subversion-1.6.17.tar.gz 下載地址: http://subversion.tigris.org/
4. subversion-deps-1.6.17.tar.gz
5. httpd-2.2.19.tar.gz 下載地址:http://httpd.apache.org/




安裝套件
1、安裝apr
tar zxvf apr-1.4.5.tar.gz #解壓包
cd apr-1.4.5
./configure --prefix=/home/svn

make;make install
2、安裝apr-util
tar zxvf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --with-apr=--prefix=/home/svn --prefix=/home/svn
make;make install
3、安裝 apache
tar zxvf httpd-2.2.19.tar.gz
cd httpd-2.2.19
./configure --prefix=/home/svn --enable-dav --enable-so --enable-maintainer-mode --with-apr=/home/svn/bin/apr-1-config --with-apr-util=/home/svn/bin/apu-1-config

make;make install
4、安裝subversion
tar zxvf subversion-1.6.17.tar.gz
tar zxvf subversion-deps-1.6.17.tar.gz
cd subversion-1.6.17
./configure --prefix=/home/svn --with-apxs=/home/svn/bin/apxs --with-apr=/home/svn --with-apr-util=/home/svn
make;make install

Configure apache and SVN

vi /home/svn/conf/httpd.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

DAV svn
SVNParentPath /home/svn/resp
#AuthzSVNAccessFile /opt/svn/conf/authz.conf
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /home/svn/passwd.conf
Require valid-user

建svn repo
svnadmin create /home/svn/repo
建立本地訪問控制文件
/home/svn/bin/htpasswd -c /home/svn/conf/passwd.conf username
/home/svn/bin/htpasswd -c /home/svn/conf/passwd.conf username1
然後輸入密碼即可,默認是MD5加密的
建立本地項目控制文件
touch /opt/svn/conf/authz.conf

authz.conf內容為:

[groups]
#=,
admin=username

#[:projectName/directory]
#@=
#=

[/]
@admin = rw #指定用戶組成員可以讀寫根目錄所有應用
[repos:/abc/aaa]
username1= rw #指定用戶username1可以讀寫:/abc/aaa目錄的文件
啟動apache
/home/svn/bin/apachectl start


在commit時,如果發生以下的問題

Permission denied
svn: Commit failed (details follow):
svn: Can't create directory '/opt/svndata/repos/db/transactions/0-1.txn': Permission denied
請使用以下方法:
chown -R daemon /home/svn/repos
chmod -R 755 /home/svn/repos


使用與設定websvn
Download websvn 2.3.3 http://websvn.tigris.org/servlets/ProjectDocumentList
Download php 5.3.6 http://php.net/downloads.php
安裝php 5.3.6

tar xzvf php-5.3.6.tar.gz
cd php-5.3.6
./configure --with-apxs2=/home/svn/bin/apxs --prefix=/home/svn/php --with-config-file-path=/home/svn/php --disable-cgi --with-zlib --with-gettext --with-gdbm
make;make install
cp -p .libs/libphp5.so /home/svn/modules
cp -p php.ini-production /home/svn/php/php.ini
Add the following lines to httpd.conf:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script php
DirectoryIndex index.html index.php
AddType text/html php
AddType application/x-httpd-php-source phps


SetOutputFilter PHP
SetInputFilter PHP

安裝websvn
Copy websvn directory to /home/svn/htdocs
rename /home/svn/htdocs/websvn/include/distconfig.php to config.php
Remove # and change path in config.php:
$config->parentPath("/home/henbin/svn/repo");
Add the following lines to httpd.conf:

AuthType Basic
AuthName "WebSvn auth"
AuthUserFile /home/svn/conf/svn-auth-file
Require valid-user

注意事項:
1. 如果將/home/svn打包後,放置不同版本的fedora,比如fedora 9->fedora14,可能會發生找不到library,這時就要把有問題的套件重新configure與make。

沒有留言: