Installing Trac without root privs

March 20, 2008 – 12:13 pm

Trac is a most excellent bugtracking, visit wiki, version control, <insert other things relevant to development> system. However, the default instructions for installing Trac require root (superuser) privs, which isn’t possible if you use a shared server (I do) or don’t have sudo on the box you’re trying things out on (or for whatever reason, want to isolate your Trac install). Fortunately, the fix is easy; use virtualenv.

I haven’t seen these instructions up anywhere, so I’m posting them here (if someone would like these on the Trac wiki, feel free to port them over, or to ask me to). Thanks to Noah (coderanger) who suggested using virtualenv (by Ian) early on, saving a lot of unnecessary pain.

First, if you don’t have root and your default python install (type “python -V” at your prompt) is earlier than python2.4, you’ll want to custom-install Python2.5 or some other more recent version. Instructions on how to do that are here. After you’ve got python2.4 or later, you can proceed.

# get the code...
wget #md5=fb86aabdfc2033612b936cf08ad811ec
tar zxfv virtualenv-1.0.tar.gz # untar/unzip
mv virtualenv-1.0/ ./ # copy out the python files
rm -r virtualenv-1.0 # not strictly necessary, but cleans stuff up
rm virtualenv-1.0.tar.gz # ditto
python . # to install virtualenv in your current directory

(If you want to install virtualenv somewhere else, run python somewhere_else as the last command instead.) You should now have a /bin and a /lib in your current directory. Now you can follow the Trac installation guide, using the stuff in ./bin/python.

bin/easy_install Pygments
bin/easy_install Genshi
bin/easy_install Trac

That’s it. And now you can create your project wherever you like (replace /path/to/yourproject with whatever you want – /home/yourusername/nameofproject or whatnot) and test it…

bin/trac-admin /path/to/yourproject initenv
bin/tracd --port 8000 /path/to/yourproject

and then go to http://localhost:8000 or to check it out. Follow the instructions on the Trac wiki guide thereafter to customize Trac and deploy it on a “real” (non-tracd) webserver – just use your virtualenv’s bin/python python-instance.

Suggestions, corrections, and clarifications are, as usual, welcome.

Know someone who'd appreciate this post?
  • Print
  • Facebook
  • Twitter
  • Google Bookmarks
  • email
  1. 6 Responses to “Installing Trac without root privs”

  2. I have a slightly awkward question about this: how would using virtualenv relate to installing Python on Dreamhost with the “Unix account setup”?

    That is, is the use of the Unix account setup actually unnecessary in order to get a Python environment running on Dreamhost that’s separate from the globally installed one, given that virtualenv will give you the same sort of effect with much less hassle? Or am I getting the wrong end of the stick?

    Is virtualenv similar to using the virtual python approach?

    (:feeling dense:)

    By Sam Pablo Kuper on May 17, 2008

  3. I think I’ve actually answered those questions now. All I’m still trying to work out is which of the two approaches – “Unix account” or virtualenv – to prefer. Suggestions welcome!

    And regardless of my finicky points, thanks for the helpful tutorial!

    By Sam Pablo Kuper on May 17, 2008

  4. is almost certainly a better tutorial (if you leave the tracd process running, Dreamhost complains). I haven’t tried working through it yet, though.

    It looks like the virtual-python script you pointed to is intended to do the same thing as virtualenv.

    By Mel on May 18, 2008

  5. OK, so I’ve got as far as running

    bin/tracd –port 8000 /path/to/yourproject

    but when I access the corresponding URL in a browser, although I get a Trac welcome screen (yay!) there’s an error message at the top of it: “Warning: Can’t synchronize with the repository (Unsupported version control system “svn”. Check that the Python support libraries for “svn” are correctly installed.)”

    The advice here isn’t terribly helpful because it assumes root access. Nonetheless, the suggestion of trying

    from svn import core

    at the Python interpreter is useful. In my case, I get an error. But what’s the solution? Er, I don’t know. I’m guessing that it’s a path issue or a something-more-needs-to-be-installed issue, but I don’t know which yet.

    Help welcome :)

    By Sam Pablo Kuper on May 18, 2008

  6. The sticking point for me with DreamTracInstall is assumption 3: “You don’t have python installed to your local home directory.”

    Well, I’m not entirely clear what this means, but if it means, “You haven’t custom-installed Python,” then assumption 3 doesn’t apply to me, because I have custom-installed Python, following the instructions from the link in your post above. And if I want to deploy Django or web2py, I’m guessing I’ll need that custom-install, so I’m loath to remove it.

    Mmm, I’m definitely stuck at this point. I’ll probably have to come back to this another day.

    By Sam Pablo Kuper on May 18, 2008

  7. Ok, I thought I’d have a go with DreamTracInstall. I removed the custom-installed Python25, and followed the DreamTracInstall instructions to the letter.

    The results were semi-successful. The script put the contents of the htdocs folder in the wrong place, but I moved them to the directory for the relevant domain and voila, Trac! But although the front page works, links from it don’t: they’re causing HTTP 500 internal server errors.

    A quick look at the logs suggests they are creating mod_rewrite loops that won’t resolve. What’s less clear is how to fix this. Bleh, Trac is nasty.

    By Sam Pablo Kuper on May 18, 2008

What do you think?