Version 18 (modified by 19 years ago) ( diff ) | ,
---|
These instructions were written for a fresh install of Ubuntu(Hoary). I used the Ubuntu Custom install which creates a very bare-bones system - no X server or other niceties. Just the ticket for a lightweight, nimble server!
These instructions should work OK under other conditions (full install, existing systems) as well.
FYI, Trac has trouble with Ubuntu's WartyWarthog
release; it needs versions of python-SQLite and clearsilver that aren't available on Warty (see #468 & #1104). So I upgraded my fresh Warty install to the HoaryHedgehog
release. A fresh Hoary install should be ok but I didn't test that.
To upgrade from Warty to Hoary, I changed my /etc/apt/sources.list to look like this:
## Main & restricted deb http://archive.ubuntu.com/ubuntu hoary main restricted deb-src http://archive.ubuntu.com/ubuntu hoary main restricted ## Universe (needed for the Trac install) deb http://archive.ubuntu.com/ubuntu hoary universe deb-src http://archive.ubuntu.com/ubuntu hoary universe ## Security deb http://security.ubuntu.com/ubuntu hoary-security main restricted deb-src http://security.ubuntu.com/ubuntu hoary-security main restricted
… then ran the following commands to actually perform the update:
sudo apt-get update sudo apt-get -y upgrade
You can take a nice long break while Hoary is downloaded and installed.
Once that's done, we have a brand-new Hoary install. The rest of these instructions look painful, but really the hardest part is now over. With a fast net connection, you can do the rest of this in 10-15 minutes.
We need to install a few more things:
sudo apt-get install trac sudo apt-get install libapache2-svn
NOTE: You should also do an apt-get install python before installing trac. Apparently, apt-get failed to install python properly and cause some errors on in the later commands. The only caveat here is that apt-get install python will uninstall gde so beware!!! Do an apt-get install gde to restore the desktop… if you installed the desktop, that is. Also, take a look near the end of this file for how the original author solved the python issue without doing this. Could be that python changed in the Hoary repository?
NOTE: Throughout the rest of this text I use YourProjectNameHere
as the project name. Clearly, you'll want to replace this with a name for your own project!
Configure Apache for by editing /etc/apache2/sites-available/default. When you're done the file will look like this (I think my changes are pretty obvious - they are preceded by the comment lines IN ALL CAPS):
NameVirtualHost * <VirtualHost *> ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place # Commented out for Ubuntu #RedirectMatch ^/$ /apache2-default/ </Directory> ## ---THESE LINES FROM ORIGINAL FILE WERE COMMENTED OUT--- # ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ # <Directory "/usr/lib/cgi-bin"> # AllowOverride None # Options ExecCGI -MultiViews +SymLinksIfOwnerMatch # Order allow,deny # Allow from all # </Directory> ## ---END OF COMMENTS--- ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> ## ---THESE LINES WERE ADDED TO THE ORIGINAL FILE--- Alias /trac "/usr/share/trac/htdocs" ScriptAlias /cgi-bin/ /usr/share/trac/cgi-bin/ <Location "/cgi-bin/trac.cgi"> SetEnv TRAC_ENV "/var/trac/YourProjectNameHere" </Location> <Directory "/usr/share/trac/htdocs"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> # You need something like this to authenticate users <Location "/cgi-bin/trac.cgi/login"> AuthType Basic AuthName "YourProjectNameHere" AuthUserFile /var/www/trac.htpasswd Require valid-user </Location> #SVN dir <Location /svn> DAV svn SVNParentPath /var/svn </Location> ## ---END OF ADDITIONS--- </VirtualHost>
Alternatively, instead of making a mess of your nice default vhost, why not take advantage of the vhost setup that unbuntu kindly has already set up for you.
Make a new file called /etc/apache2/sites-available/trac and put this in it.
<VirtualHost *> ServerAdmin webmaster@localhost ServerName trac.example.com DocumentRoot /usr/share/trac/cgi-bin/ <Directory /usr/share/trac/cgi-bin/> Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride All Order allow,deny allow from all </Directory> Alias /trac "/usr/share/trac/htdocs" <Location /trac.cgi> # You may need to customize this SetEnv TRAC_ENV "/var/trac" </Location> DirectoryIndex trac.cgi ErrorLog /var/log/apache2/error.trac.log CustomLog /var/log/apache2/access.trac.log combined </VirtualHost>
Note that you'll also need to make the following change to the apache2.conf file. (which some people don't like doing, I've never understood why not) Make sure that the AddHandler
line is uncommented.
# To use CGI scripts outside /cgi-bin/: # AddHandler cgi-script .cgi
Then, use sudo a2ensite trac
and restart apache, and you're good to go. Now you have your normal site left as before, running at www.example.com and your trac project running at trac.example.com. Feel free to go and play with the rewrite rules to pretty it up further, but now, back to the rest of the setup.
I installed my Subversion repository at /var/svn/YourProjectNameHere
. So I did a quick starting config of subversion with the following commands:
sudo mkdir /var/svn sudo mkdir /var/svn/YourProjectNameHere sudo mkdir /tmp/YourProjectNameHere sudo mkdir /tmp/YourProjectNameHere/branches sudo mkdir /tmp/YourProjectNameHere/tags sudo mkdir /tmp/YourProjectNameHere/trunk sudo svnadmin create /var/svn/YourProjectNameHere sudo svn import /tmp/YourProjectNameHere file:///var/svn/YourProjectNameHere -m "initial import" sudo rm -rf /tmp/YourProjectNameHere
Some permissions changes and an apache restart are now needed:
sudo chown -R www-data /var/svn/YourProjectNameHere sudo chown -R www-data /usr/share/trac sudo apache2 -k restart
Test by web-browsing to http://servername/svn/YourProjectNameHere
If you see a simple web page which says Revision 1: / and lists branches, tags, and trunk, your Subversion install is up and running!
Now let's finish the Trac install (but don't go on to Trac install until you have the above working properly).
I put my trac environment at /var/trac/YourProjectNameHere
. Of course you could use any other path or name - something a little more descriptive of your project would probably be a good idea. First I ran these commands:
sudo mkdir /var/trac sudo trac-admin /var/trac/YourProjectNameHere initenv sudo chown -R www-data /var/trac/YourProjectNameHere
The "trac-admin" command shown above prompted me to enter:
- the project name (
YourProjectNameHere
) - the path to svn repository (
var/svn/YourProjectNameHere
) - the path to the Trac templates directory (
usr/share/trac/templates
)
… then it prints out a bunch of stuff. If there are no errors you should now be able to surf to your Trac site at http://servername/cgi-bin/trac.cgi
At the time I did my install, there was one glitch in the Ubuntu Universe Trac installer. It doesn't install the neo_cgi.so file needed in the python2.4 directory space. So when I surfed to my Trac site, I got the error ImportError: No module named neo_cgi. I was able to fix this by symlinking the python2.3 version like so:
sudo ln -s /usr/lib/python2.3/site-packages/neo_cgi.so /usr/lib/python2.4/site-packages/neo_cgi.so
Voila! Your Trac system & website should be up and running.
OPTIONAL: create a redirect file called /var/www/index.html with this one line:
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://10.0.0.102/cgi-bin/trac.cgi">
… with this change, you can get to Trac with http://servername instead of the more cumbersome http://servername/cgi-bin/trac.cgi
putting your trac.htpasswd file into /var/www might not be such a good idea though, since that might be served by apache to the outside