2013年9月4日 星期三

[記事] Trac installation

屬於阿宅世界的技術文章,想看的再點開,切莫自誤 !




Trac is awesome , but the installation is awful = =!

First of all , you need Python.There are two branches (2.x and 3.x) , and what I use is 2.7.

Install pip


# wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py --no-check-certificate
# python get-pip.py


with pip installed, u could now install Trac easily 
# pip install Trac

by default, you will get your Trac installed in /<PYTHON_HOME>/lib/python<VERSION>/site-packages/trac and two other binary files (trac-admin, tracd) in /PYTHON_HOME/bin 

make sure it's a directory not an egg XD

BTW, you can specify the installation directory by using -t flag

Initiate project environment


# mkdir /<TRAC_HOME>/projects
# /<PYTHON_HOME>/bin/trac-admin /<TRAC_HOME>/projects/<YOUR_PROJECT_NAME> initenv

if you choose sqlite 3 as your trac db and encoun the _sqlite3 modules not found error , try to modify the setup.py of python and add the sqlite include path the sqlite_inc_paths (eg, '/usr/local/include/sqlite3' ), rebuild and re-install your python


create the first (admin) user and grant hime the TRAC_ADMIN privilege
# <PYTHON_HOME>/bin/trac-admin /<TRAC_HOME>/projects/<YOUR_PROJECT_NAME> permission add admin TRAC_ADMIN

now you can start the trac as a standalone server by tracd.

Run as a fast-cgi in lighttpd


beside as a standalone server , Trac could "Connect to " your current web-server. The following steps shows how to configu it in lighttpd

First, enable the fast-cgi module in lighttpd.conf
server.modules = ( ..., "mod_fastcgi", ... )

Add the following in lighttpd.conf

var.trac_fcgi_binary="/<PYTHON_HOME>/lib/python<VERSION>/site-packages/trac/web/fcgi_frontend.py"

fastcgi.server = ( "/<TRAC_PREFIX>/<YOUR_PROJECT_NAME>" =>
                     (
                       ("socket" => "/tmp/trac-fastcgi.socket",
                        "bin-path" => trac_fcgi_binary,
                        "min-procs" => 2,
                        "max-procs" => 2,
                        "check-local" => "disable",
                        "bin-environment" =>
                          ("TRAC_ENV" => "/<TRAC_HOME>/projects/<YOUR_PROJECT_NAME>")
                       )
                     )
                 )

Restart the lighttpd and now you can browse the Trac project on http://<YOUR_DOMAIN>/<TRAC_PREFIX>/<YOUR_PROJECT_NAME>

Enable basic  authentication


The most simple way to identify user is using the htpasswd file.

Generate the user/password file by htpasswd
# htpasswd -c /<TRAC_HOME>/<PWD_FILE> admin

Load the mod_auth into lighttpd and make sure it is loaded before mod_fastcgi.

Add the following into lighttpd.conf


auth.backend               = "htpasswd"
$HTTP["url"] =~ "^/<TRAC_PREFIX>/<YOUR_PROJECT_NAME>" {
        auth.backend.htpasswd.userfile = "/<TRAC_HOME>/<PWD_FILE>"
}

auth.require = (
        "/<TRAC_PREFIX>/<YOUR_PROJECT_NAME>/login" =>
                ("method"  => "basic",
                 "realm"   => "<YOUR REALM>",
                 "require" => "valid-user"
                )
)

Restart lighttpd and now you can login into Trac.


0 意見:

張貼留言