Trac is an enhanced wiki and issue tracking system for software development projects. Trac uses a minimalistic approach to web-based software project management (http://trac.edgewall.org/)Installation:
- install packages:
sudo apt-get install python python-babel trac trac-authopenid trac-git
- create trac environment. My environment is like this:
- /trac (Trac Parent Directory)
- /trac/myproject (my project directory
sudo mkdir /trac sudo mkdir /trac/myproject sudo chown -R your-username:users /trac #set it to belong to you, for easier setup for now
- initial Trac project
trac-admin /trac/myproject initenv
- Edit myproject's trac config
- Go to /trac/myproject/conf/
- use your prefer editor (gedit,kate,vi) to open up "trac.ini"
- add this at the bottom for authOpenID
[components] trac.web.auth.* = disabled authopenid.* = enabled
- Enable file logging(save to /trac/myproject/log/trac.log) by changing "log_type = none" to "log_type = file"
- set Header Logo, under "[header_logo]" edit the config like this:
[header_logo] alt = My Project height = 200 link = src = site/images/logo.png width = 800
"site/" means your local "htdocs" (/trac/myproject/htdocs). Meaning it will search for "logo.png" under /trac/myproject/htdocs/images/logo.png - set other settings if you would like
- Try running it on standalone first, to see if the configuration works. Use command: "tracd -p 8888 /trac/myproject" .
- If it is working you can browse to localhost:8888 and it should be running smoothly.
- don't forget to login with OpenID, by clicking "OpenID Login" on top-right corner. So we can capture the OpenID username and use it later
- you can stop the server on the command line terminal by pressing Ctrl-C
- Setting OpenID user. Since we turned on logging to file, and we tried logged in with OpenID user.
- see the log(using vi,tail,kate,gedit) on log file located at /trac/myproject/log/trac.log
- What you are looking for is something like this
2012-08-30 04:39:28,131 Trac[session] DEBUG: Retrieving session for ID u'anidear'
The OpenID user name is in u'xxxxxxx'. In this case, it is "anidear". - Using trac-admin command to grant permission to this user if he is an admin
trac-admin /trac/myproject permission add anidear TRAC_ADMIN
where as "anidear" is my username from previous step.
- Update Trac settings using command
trac-admin /trac/myproject upgrade
- (Optional) You may need to remove all wiki pages. It can be done by this script
#!/bin/sh # extract the page list from trac (this filter matches only CamelCase words or numbers, # it will blow if there are pages which does not fit into this scheme) for site in `trac-admin /trac/myproject wiki list | sed -e 's/\([a-zA-Z0-9]*\).*/\1/'` do # and remove every single page trac-admin /trac/myproject wiki remove $site done
ref: http://stackoverflow.com/questions/3978755/trac-pages-delete-all - Change permission so Apache can read/write to it.
But I'm single user on this machine and I want to modify the file sometimes. So I'll just set the group for "www-data" (Apache group) just enough for Apache to read the file. Otherwise, you can set both user and group to belong to Apache buy using "www-data:www-data" for it.sudo chown -R :www-data /trac sudo chmod -R 775 /trac
- Setting Trac to works with Apache2:
- go to /etc/apache2/sites-available and create a file named "trac-site" (need root privilege) by using any editor
- put this in the file:
Listen 0.0.0.0:9999 NameVirtualHost *:9999 <VirtualHost *:9999>
ServerName trac.local <Location /> </VirtualHost>SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend # PythonOption TracEnv /trac/myproject PythonOption TracEnvParentDir /trac PythonOption TracUriRoot / PythonOption TracLocale en_US.UTF8 PythonOption PYTHON_EGG_CACHE /tmp Order allow,deny Allow from all </Location> # <Location /login># AuthType Basic # AuthName "myproject" # AuthUserFile /trac/.htpasswd # Require valid-user # </Location> ErrorLog /var/log/apache2/trac_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/trac_access.log combined - Listen 0.0.0.0:9999 set to accept any IP that comes to server with port 9999 (you can limit to use within your machine by changing 0.0.0.0 to 127.0.0.1)
- NameVirtualHost and VirtualHost are accepting any IP on port 9999 (again, to make it private change * to 127.0.0.1)
- "<Location />" is for serving Trac as the root of URL "http://localhost:9999/"
- "PythonOption TracEnv" is for using single project. If you want to use only single project, uncomment this line
- "PythonOption TracEnvParentDir" points to parent directory of projects
- "PythonOption TracUriRoot" is the URL that we want to use when request for Trac main page. "/" means to "http://localhost:9999/"
- I comment out normal Trac authentication using htpasswd because we already change to use OpenID authentication.
- "ErrorLog","CustomLog","LogLevel" are settings for keep logging on Trac and location to save the logs to
- use command "sudo a2en trac-site" to enable this site on Apache2
- restart Apache2 using "sudo service apache2 restart"
References:
- Setting Trac on Ubuntu : http://trac.edgewall.org/wiki/TracOnUbuntu
- Setting Trac's authOpenID (manually) : http://blog.119labs.com/2010/01/installing-auth-openid-on-trac-with-dreamhost/
- Script to delete all wiki : http://stackoverflow.com/questions/3978755/trac-pages-delete-all
- Setting Trac on Ubuntu : http://trac.edgewall.org/wiki/TracOnUbuntu
- Setting Trac's authOpenID (manually) : http://blog.119labs.com/2010/01/installing-auth-openid-on-trac-with-dreamhost/
- Script to delete all wiki : http://stackoverflow.com/questions/3978755/trac-pages-delete-all
No comments:
Post a Comment