Setting up Trac Authentication on Dreamhost VPS

From time to time I use Dreamhost’s one-click-install version of Trac for a project.  I always forget the steps I have to go through to get it working, so, for posterity, here’s how it works.  This will set up a Trac site that allows the general public to visit your Trac site, but allows people who have commit permissions on SVN to login to the admin side of the site.  It also sets up email notifications.

  1. First setup the new domain from the Manage Domains panel and create subdomains for SVN and for Trac, e.g. svn.mydomain.com and trac.mydomain.com (assuming you’ll host the live project at some place like www.mydomain.com).  Make sure to enable Passenger for the Trac domain and set the directory to /home/username/trac.mydomain.com/public.  It’s important that all of these domains use the SAME username.
  2. Go to the Goodies > Subversion panel and setup the SVN repository, making sure to check the box to also set up a Trac install.  This will setup the Trac install inside of /home/username/trac.mydomain.com/public and also create a directory /home/username/trac_mydomain_com_public_trac with all of the Trac resources necessary.
  3. cd into /home/username/trac.mydomain.com/public and create admin users with the following:
    trac-admin . permission add adminusername TRAC_ADMIN
  4. SSH into the new user’s account.  Download the Trac AccountManager plugin from trac-hacks.org:
    svn co http://trac-hacks.org/svn/accountmanagerplugin/0.11 accountmanager
  5. cd into the accountmanager directory and build the plugin with the following command:
    python setup.py bdist_egg
  6. Copy the .egg file created in the accountmanager/dist folder into /home/username/trac.mydomain.com/public/plugins
  7. (Optional) If you want to personalize with your own logo, upload the logo file to /home/username/trac.mydomain.com/public/chrome/site
  8. Edit the trac.ini file in /home/username/trac.mydomain.com/public/conf as follows:
    [account-manager]
    password_file = /home/username/svn/mydomain.passwd
    password_store = HtPasswdStore
    [components]
    trac.web.auth.LoginModule = disabled
    acct_mgr.web_ui.LoginModule = enabled
    acct_mgr.web_ui.RegistrationModule = disabled
    [header_logo]
    height = your logo's height
    src = site/your_logo_filename.png
    width = your logo's width
    [notification]
    smtp_enabled = true
    smtp_from = trac@mydomain.com
    smtp_replyto = trac@mydomain.com<span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">
  9. Edit the .htaccess file in /home/username/trac.mydomain.com/public to allow your logo file to be shown by adding the following line after the line that says
    # Keep the graphics and style sheet the way they are
    RewriteCond $1 !^chrome/site(.*).png$

Note that on that last step, if your logo file is some other file type, e.g. gif, that you should swap out .png for .gif or whatever.

That should do it!  Not that difficult, and doesn’t require any major hacks to the default infrastructure provided by Dreamhosts’s one-click-install.  Of course it always takes me much longer than it should since I have to figure it out again every time I do it.

Share

4 Responses to “Setting up Trac Authentication on Dreamhost VPS”


  • Ahhhhhhh! AHHHHHHH!

    Thank you so much. I’ve been beating my head on my desk for hours trying to get this to work. I was doing most everything but I’m sure something in the configuration was screwed. Yay!

  • Another hitch. I was recently installing a new Trac site and wanted to use Trac 0.12. I was successful in getting it installed but kept getting 500 errors until I chmod 755′ed the trac.fcgi script that runs the site.

  • Another update. The AccountManager plugin has been updated and they’ve changed the name of one of the configuration settings. Change:

    password_file = /path/to/.htpasswd

    to

    htpasswd_file = /path/to/.htpasswd

    This killed a couple of hours of my afternoon. :(

  • This trac authentication guide was really helpful..

    Why didn’t I find the guide earlier. It could have save me lots of time.

    Thanks once again.

Leave a Reply