☆ 1. 安裝必要的套件
Step
|
Command
|
Note
|
1
|
[root@localhost ~]# yum install subversion mod_dav_svn httpd \ httpd-devel gcc python sqlite
|
Install essential packages
|
2
|
[root@localhost ~]# wget http://peak.telecommunity.com/dist/ez_setup.py
[root@localhost
~]# python ./ez_setup.py
|
Create easy_install command
|
3
|
[root@localhost ~]# easy_install Pygments
[root@localhost ~]# easy_install docutils
[root@localhost ~]# easy_install pysqlite
|
Install Python packages
|
4
|
[root@localhost ~]# tar xzvf sqlite-autoconf-3071700.tar.gz
[root@localhost ]# cd sqlite-autoconf-3071700
[root@localhost sqlite-autoconf-3071700]# ./configure
[root@localhost
sqlite-autoconf-3071700]# make && make install
|
或是直接安裝. |
5
|
[root@localhost ~]# tar xzvf mod_wsgi-3.4.tar.gz
[root@localhost ]# cd mod_wsgi-3.4
[root@localhost mod_wsgi-3.4]# ./configure
[root@localhost mod_wsgi-3.4]# make && make install
|
website
|
6
|
[root@localhost ~]# easy_install Genshi==0.6
[root@localhost ~]# easy_install Babel==0.9.5
[root@localhost ~]# easy_install Trac==0.12
|
Install Trac (註)
|
(註) 視個人需要選擇 Trac 的版本,Genshi, Babel 的版本也要匹配。
請參考 Trac 的官方網站。
☆ 2. Create SVN Environment
[root@localhost ~]# cd /projects
[root@localhost projects]# mkdir -p /projects/svn/prj1
[root@localhost projects]# svnadmin create --fs-type fsfs /projects/svn/prj1
|
☆ 3. Create Trac Environment and trac_admin User
[root@localhost ~]# cd /projects
[root@localhost projects]# mkdir -p /projects/trac/prj1
[root@localhost projects]# trac-admin /projects/trac/prj1 initenv
Project Name [My Project]> My First Project
Database connection string [sqlite:db/trac.db]> [Enter]
Repository type [svn]> [Enter]
Path to repository [/path/to/repos]> /projects/svn/prj1
(successful message)
[root@localhost projects]# trac-admin /projects/trac/prj1 permission \
add <自行輸入username> TRAC_ADMIN
|
☆ 4. Modify Trac Configuration
4-1. Create modwsgi config to enable Trac service
[root@localhost projects]# vim /projects/trac/prj1/trac.wsgi
import sys
sys.stdout = sys.stderr
import os
os.environ['TRAC_ENV'] = '/projects/trac/prj1'
os.environ['PYTHON_EGG_CACHE'] = '/projects/trac/prj1/.eggs'
import trac.web.main
application = trac.web.main.dispatch_request
:wq!
|
4-2. Change Trac Settings
[root@localhost projects]# vim /projects/trac/prj1/conf/trac.ini
[header_logo]
height = 28
link = http://YOUR_IP/trac/prj1
src = site/logo.gif (this file should be in htdocs/)
width = 319
…
…
…
repository_dir = /projects/svn/prj1/
repository_sync_per_request = (default) (keep default)
repository_type = svn (keep default)
:wq!
|
☆ 5. Modify Subversion Configuration
5-1. Modify svnserve.conf
[root@localhost projects]# vim /projects/svn/prj1/conf/svnserve.conf
[general]
anon-access = none (change anonymous permission)
auth-access = write (keep auth-user permission)
password-db = passwd (enable control access file)
:wq!
|
5-2. Create user and password for svn
[root@localhost projects]# vim /projects/svn/prj1/conf/passwd
[users]
# harry = harryssecret
# sally = sallyssecret
<username> = <password> (password use plain code)
:wq!
|
☆ 6. Modify httpd Configuration
6-1. /etc/httpd/conf/httpd.conf
加入以下三行,LoadModule wsgi_module modules/mod_wsgi.so
...
...
...
AddType text/html .py
WSGISocketPrefix run/wsgi
|
6-2. Subversion Config file for httpd
[root@localhost projects]# vim /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location "/svn/prj1">
DAV svn
SVNPath /projects/svn/prj1
AuthType Basic
AuthName "My Own SVN"
AuthUserFile /projects/svn/prj1/conf/.passwd
Require valid-user
</Location>
:wq!
|
6-3. Trac Config file for httpd
[root@localhost projects]# vim /etc/httpd/conf.d/trac.conf
WSGIDaemonProcess realtek user=apache group=apache threads=25
WSGIScriptAlias /trac/pjr1 /projects/trac/prj1/trac.wsgi
<Directory /projects/trac/prj1>
WSGIProcessGroup Project1
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
<Location /trac/prj1>
AuthType Basic
AuthName "My Own Project"
AuthUserFile /projects/svn/prj1/conf/.passwd (same as subversion.conf, because same project)
Require valid-user
</Location>
:wq!
|
6-4. Create user password for httpd
[root@localhost projects]# touch /projects/svn/prj1/conf/.passwd
[root@localhost projects]# chown -R root.apache /var/svn/.passwd
[root@localhost projects]# htpasswd -d /projects/svn/prj1/conf/.passwd <username>
<keyin password messages>
|
☆ 7. Import Source Code to SVN Server
* Create folders and import source code
[root@localhost projects]# service svnserve restart
[root@localhost projects]# cd /tmp
[root@localhost tmp]# mkdir -p /tmp/prj1/tags
[root@localhost tmp]# mkdir -p /tmp/prj1//branches
[root@localhost tmp]# mkdir -p /tmp/prj1/trunk
[root@localhost tmp]# copy your source codes to /tmp/prj1/trunk/
[root@localhost tmp]# svn import prj1 --no-ignore --force \
svn://Your_IP/projects/svn/prj1/
|
svn import 時加上「--no-ignore –force」可以避免有些 binary, object 被排除了而沒上 svn repository.
☆ 8. Start httpd + trac + svn service
8-1. Change access attribute of relative folders
[root@localhost projects]# chmod -R 770 /projects/trac/prj1
[root@localhost projects]# chmod -R 770 /projects/svn/prj1
[root@localhost projects]# chown -R apache.svn /projects/trac/prj1
[root@localhost projects]# chown -R apache.svn /projects/svn/prj1
|
8-2. Add a test user
[root@localhost projects]# useradd testuser
[root@localhost projects]# passwd testuser (for linux login)
[root@localhost projects]# htpasswd -d /projects/svn/prj1/conf/.passwd testuser (for httpd)
<keyin password messages>
|
8-3. Startup web server
[root@localhost projects]# service svnserve restart
Stopping svnserve: [ OK ]
Starting svnserve: [ OK ]
[root@localhost projects]# chkconfig svnserve on (make svn start when boot)
[root@localhost projects]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost projects]# chkconfig httpd on (make httpd start when boot)
|
8-4. Access Trac via web browser
Open IE/Firefox/Chrome, visit:
http://Your_IP/trac/prj1
操作 svn 指令的 URL 為 http://Your_IP/svn/prj1
例 :
[tester@localhost ~] % svn co http://Your_IP/svn/prj1/trunk
沒有留言:
張貼留言