Skip to content


การติดตั้ง SVN & Trac ร่วมกับ Apache ใน Ubuntu

ช่วงนี้กำลังปรับปรุงระบบ SVN ใหม่อยู่ โดยจะให้การทำ authen ผ่าน .htaccess เดียวกันทั้ง SVN & Trac
จึงได้นำ SVN และ Trac มาผูกรวมกับ Apache ซึ่งเป็นวิธีการติดตั้งที่ง่ายกว่า และสะดวกกว่าการติดตั้งแบบที่นำเสนอครั้งก่อน โดยอาศัย dav_svn กับ mods_python เข้ามาช่วย

จาก WikiBall

เนื้อหา



ติดตั้ง Program ใน Ubuntu


SVN + Apache

ติดตั้ง apache

$ sudo apt-get install apache2

ติดตั้ง svn

$ sudo apt-get install subversion

ติดตั้งโมดูล svn ของ apache

$ sudo apt-get install libapache2-svn


Trac + Apache

การติดตั้ง Trac จำเป็นต้องมี SVN อยู่ก่อนแล้ว
จึงทำการติดตั้ง Trac ดังนี้
ดาวโหลด trac มาใส่ไว้ในที่ไดที่หนึ่งอาจเป็น /home/user ก็ได้ หรืออาจให้ wget ดึงมาเลย

wget http://ftp.edgewall.com/pub/trac/Trac-0.11.5.tar.gz

ระเบิดมัน

tar -xzf Trac-0.11.5.tar.gz

ลง Python setup

$ sudo apt-get install python-setuptools

เข้าไปที่ directory ดังกล่าว Trac-0.11.5 แล้วทำการ install

$ sudo python ./setup.py install


การสร้าง project


สร้าง repository

ตัวอย่างการสร้าง

$ svnadmin create /var/svn/repository/example

นำเข้า (import) project

$ svn import /path/to/projectexample file:///var/svn/repository/example/examplev1 -m"initial import" 


สร้าง Trac

การสร้าง project enviroment รันคำสั่ง

$ trac-admin /path/to/myproject initenv

ดู option ต่างๆ ได้ที่ การใช้งาน trac


Enable apache modules

เราต้องทำการ enable apache modules โดยการทำ soft link ใน /etc/apache2/mods-enabled ไปยัง /etc/apache2/mods-available/

$ cd /etc/apache2/mods-enabled
$ sudo ln -s ../mods-available/dav_svn.conf
$ sudo ln -s ../mods-available/dav_svn.load
$ sudo ln -s ../mods-available/mod_python.load


Apache configure

หลังจากลงโปรแกรม แล้ว เราก็จะมากทำการ config เจ้าตัว apache ของเราให้สามารถทำงานได้กัน โดยก่อนอื่นต้องเข้าไปที่ /etc/apache2/sites-available/


configuration file สำหรับ trac

สร้าง config file ใหม่

$sudo vim trac
<Location /uri/path/to/trac/project>
        SetHandler mod_python
        PythonInterpreter main_interpreter
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnv /path/to/project/environment
        PythonOption TracUriRoot /uri/path/to/trac/project
</Location>

ถ้าต้องการทำ authentication ผ่าน .htaccess ของ apache ให้เพิ่มโค้ดด้านล่าง ลงใน Location

        AuthType Basic
        AuthName "Project name"
        AuthUserFile /path/to/.htaccess
        Require valid-user


configuration file สำหรับ subversion

สร้าง config file ใหม่

$sudo vim svn
<Location /uri/path/to/svn/project>
        DAV svn
        SVNPath /var/svn/repository/rddi/mailgoth/
</Location

ถ้าต้องการทำ authentication ผ่าน .htaccess ของ apache ให้เพิ่มโค้ดด้านล่าง ลงใน Location

        AuthType Basic
        AuthName Foo
        AuthUserFile /var/svn/repository/rddi/mailgoth/.htaccess

        require valid-user
        Order deny,allow


Enable site

ทำการ Enable site

$ cd /etc/apache2/sites-enabled/
$ sudo ln -s ../sites-available/svn 002-svn
$ sudo ln -s ../sites-available/trac 002-trac


วิธีสร้าง .htaccess

htpasswd -c .htaccess username


Restart apache

สั่ง restart apache

 $ sudo apache2ctl restart

ถ้าเข้าแล้วยังมี error อยู่ ให้ไปดูที่ /var/log/apache/error.log ว่ามี Error อะไรเกิดขึ้น


การใช้งาน

  • เข้าใช้งาน Trac : http:/site.name/uri/path/to/trac/project
  • เข้าใช้งาน SVN : http:/site.name/uri/path/to/svn/project

รับข้อมูลจาก (Reference) :

จาก WikiBall : http://wiki.memoball.info/index.php/SVN+Trac+apache2

เพิ่มเติม

Posted in Linux. Tagged with , , , .

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. ปัญหาการใช้ web interface ของ trac – MEMOBALL.info linked to this post on October 2, 2009

    [...] หลังจากสร้าง wiki เป็นของตัวเอง จึงได้รวบรวมปัญหา และการติดตั้งเป็นอันเดียวกันใน wiki โดยมีวิธีการที่ง่าย และสะดวกกว่าที่ การติดตั้ง SVN & Trac ร่วมกับ Apache ใน Ubuntu [...]