Install of trac + subversion

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 ;-)

  1. Install of trac via synaptic
  2. 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
  3. Install of perl in apache (libapache2-mod-perl2 in synaptic) to enable the index.cgi script
  4. $ 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"
  5. So I installed libapache2-mod-python (synaptic). Yes I know I read to fast the doc, it was mentioned.
  6. 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)
  7. $ 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.
  8. Notice the config file path : /usr/share/trac/htdocs/conf/trac.ini
  9. $ tracd –port 8000 /usr/share/trac/htdocs
  10. 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 ?)
  11. $ cd /usr/share/trac/htdocs/; sudo chown -R currentUser.currrentUser db
  12. Again : $ tracd –port 8000 /usr/share/trac/htdocs
  13. Bravo ! Trac displayed… (http://localhost:8000/htdocs)
  14. 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…
  15. I was still stuck with a 500 server error if I try to load http://localhost/projects/.
  16. 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";’
  17. 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.
  18. I deleted /var/www/projects/index.cgi which is totally useless.

Step 2 : Issues left to fix :

  1. I still have the error about the missing subversion repository. Solution : install a subversion repository. Well explained here : http://trac.edgewall.org/wiki/TracUbuntuMultipleProjects
  2. 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"
  3. 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.

  1. 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)
  2. Create /etc/apache2/conf.d/trac.conf (see mine below)
  3. % sudo mkdir /var/trac
  4. % sudo chown www-data:www-data /var/trac
  5. % sudo mkdir /var/svn
  6. % sudo mkdir /var/svn/YourProjectNameHere
  7. % sudo svnadmin create /var/svn/YourProjectNameHere
  8. % sudo chown -R www-data /var/svn/YourProjectNameHere
  9. % sudo /etc/init.d/apache2 sudo restart
  10. sudo trac-admin /var/trac/YourProjectNameHere initenv
  11. sudo chown -R www-data:www-data /var/trac/YourProjectNameHere
  12. http://localhost/projects
  13. Take a breath !
  14. % sudo htpasswd -c /var/trac/.htpasswd admin [choose a password - The path is specified in /etc/apache2/conf.d/trac.conf]
  15. % sudo htpasswd /var/trac/.htpasswd <someotheruser>
  16. 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
  • Share/Bookmark