Install of trac + subversion
May 17
Project management, ubuntu subversion, trac No Comments
Step 1 : first trac installation story (you can go directly to step 3 if you don’t like install nightmares)
Here is the whole story of my trac install on a virtual ubuntu machine. Not the easy and perfect way, but I think it would be useful to see the errors too
- Install of trac via synaptic
- Followed instruction of this page : https://help.ubuntu.com/community/Trac (/etc/apache2/conf.d/trac.conf + /var/www/projects/index.cgi). I also used http://trac.edgewall.org/wiki/TracModPython. The most useful and accurate is actually http://trac.edgewall.org/wiki/TracUbuntuMultipleProjects
- Install of perl in apache (libapache2-mod-perl2 in synaptic) to enable the index.cgi script
- $ sudo /etc/init.d/apache2 restart => "… waiting Syntax error on line 31 of /etc/apache2/conf.d/trac.conf: Invalid command ‘PythonInterpreter’, perhaps misspelled or defined by a module not included in the server configuration"
- So I installed libapache2-mod-python (synaptic). Yes I know I read to fast the doc, it was mentioned.
- Point browser to http://127.0.0.1/projects/ -> Internal server error (500). In /var/log/apache2/error.log I have " OSError: [Errno 2] No such file or directory: ‘/var/trac’ (dir specified in index.cgi)
- $ sudo trac-admin /usr/share/trac/htdocs initenv (answer questions). I set a distant svn repository : http:/subversion.assembla.com/svn/myproject. This is not supported. I had to change it to my local repository later.
- Notice the config file path : /usr/share/trac/htdocs/conf/trac.ini
- $ tracd –port 8000 /usr/share/trac/htdocs
- http://localhost:8000/htdocs => "TracError: The user <currentUser> requires read _and_ write permissions to the database file /usr/share/trac/htdocs/db/trac.db and the directory it is located in." (probably, I’d rather install trac from user, no root, in my home dir ?)
- $ cd /usr/share/trac/htdocs/; sudo chown -R currentUser.currrentUser db
- Again : $ tracd –port 8000 /usr/share/trac/htdocs
- Bravo ! Trac displayed… (http://localhost:8000/htdocs)
- mmhh… Warning : Warning: Can’t synchronize with the repository (/usr/share/trac/htdocs/http:/subversion.assembla.com/svn/myproject does not appear to be a Subversion repository.). Look in the Trac log for more information.". This is because trac doesn’t support distant svn repository. Ok install subversion locally…
- I was still stuck with a 500 server error if I try to load http://localhost/projects/.
- I had to correct the /etc/apache2/conf.d/trac.conf : Replace "/var/trac" by "/usr/share/trac" in the line "PythonOption TracEnvParentDir /var/trac" (you must have "PythonOption TracEnvParentDir /usr/share/trac" to match the dir I specified with the trac-admin initenv command in step 7). I had to correct also the index.cgi file (replace ‘my $trac_path = "/var/trac";’ by ‘my $trac_path = "/usr/share/trac/htdocs";’
- Then, when I click on my project link (url=http://localhost/projects/htdocs), I have a trac error : "The user www-data requires read _and_ write permissions to the database file /usr/share/trac/htdocs/db/trac.db and the directory it is located in.". It’s the same error I had when I ran the standalone server (tracd), but now it’s apache the process owner. So I made "$ cd /usr/share/trac/htdocs/; sudo chown -R www-data db", and it made the trick.
- I deleted /var/www/projects/index.cgi which is totally useless.
Step 2 : Issues left to fix :
- I still have the error about the missing subversion repository. Solution : install a subversion repository. Well explained here : http://trac.edgewall.org/wiki/TracUbuntuMultipleProjects
- Another issue is that the url of my project is ended by "/htdocs", and it should be http://localhost/projects/myprojectname (the error was made when I ran the command "$ sudo trac-admin /usr/share/trac/htdocs initenv". It should have been : "$ sudo trac-admin /usr/share/trac/<myproject> initenv"
- Authentication (i saw a plugin authManager…)
Step 3 : Long story made short and install ok
NB. I choose to install trac home in /var/trac instead of /usr/share/trac ; and /var/svn as the root dir for all subversion repositories. To correct my first try, I mainly followed http://trac.edgewall.org/wiki/TracUbuntuMultipleProjects wich I found to be the best ressource.
- Install trac (and modules trac-accountmanager, trac-customfieldadmin, trac-email2trac, trac-mastertickets, trac-wysiwyg, trac-xmlrpc…) + perl apache module + python apache module + libapache2-svn (to have dav_svn module)
- Create /etc/apache2/conf.d/trac.conf (see mine below)
- % sudo mkdir /var/trac
- % sudo chown www-data:www-data /var/trac
- % sudo mkdir /var/svn
- % sudo mkdir /var/svn/YourProjectNameHere
- % sudo svnadmin create /var/svn/YourProjectNameHere
- % sudo chown -R www-data /var/svn/YourProjectNameHere
- % sudo /etc/init.d/apache2 sudo restart
- sudo trac-admin /var/trac/YourProjectNameHere initenv
- sudo chown -R www-data:www-data /var/trac/YourProjectNameHere
- http://localhost/projects
- Take a breath !
- % sudo htpasswd -c /var/trac/.htpasswd admin [choose a password - The path is specified in /etc/apache2/conf.d/trac.conf]
- % sudo htpasswd /var/trac/.htpasswd <someotheruser>
- You owe your cup of coffee now !
My /etc/apache2/conf.d/trac.conf
# Trac project directory (for project listing)
AllowOverride None
Options Indexes +ExecCGI MultiViews FollowSymLinks
AddHandler cgi-script .cgi
Order allow,deny
Allow from all
# use the following for one authorization for all projects
AuthType Basic
AuthName "Trac Project authentication"
AuthUserFile /var/trac/.htpasswd
Require valid-user
## Using multiple projects
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
# For multiple projects
PythonOption TracEnvParentDir /var/trac
PythonOption TracUriRoot /projects
Customisation
- sudo trac-admin /var/trac/myProjectName/
- (in trac console) permission add admin TRAC_ADMIN
- permission list admin
- quit
- Then reload trac and you must have a new "admin" tab in the right upper side
- Enable the plugins in Admin > Plugins
RSS
