Posts tagged Python
Installing Trac on 64 Bit Ubuntu 8.04 (Hardy)
Mar 9th
This is a fairly basic guide which is mostly for my reference, but feel free to use it. I do not take responsibility for server failure, data loss or if your switch starts sending toast over the internet to your computer after following this guide. Follow this rough guide at your own risk.
NOTE: This guide is roughly based on a more complete guide here
Some assumptions are going to be made here.
- You have subversion installed already and your repos are in /var/svn
- You have set this up for access via apache. (Quick Guide coming soon)
- Your websites are in their own directory in /var/sites/
First install the required programs from the universe repository. If you are using ubuntu (Hardy) server, you will need to edit the /etc/apt/repos.d file.
sudo nano /etc/apt/sources.list
Enter the following lines to the end of the file
deb http://archive.ubuntu.com/ubuntu/ hardy universe deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe
Save the file and now do the following to refresh the package list.
sudo apt-get update sudo apt-get upgrade
This will ensure that you have the latest and greatest of your currently installed packages to avoid any unforeseen problems. Now we need to install trac, you may get away with the following and apt will get any other dependencies for you.
sudo apt-get install trac
Or I used the command similar to the guide I saw.
sudo apt-get install enscript libapache2-mod-python python-docutils trac db4.3-util
Now once this is complete, create the directory for your trac instance and change the owner to the web server user. Depending on which distribution this could be httpd, apache or ww-data. In Ubuntu it is www-data.
sudo mkdir /var/sites/trac.yourdomain.com sudo chown -R www-data:www-data /var/sites/trac.yourdomain.com
And now we use the trac-admin program to initialise the environment, just follow the steps and remember where your svn repos are kept.
trac-admin /var/sites/trac.yourdomain.com initenv
Now to create the apache site, we are using named virtual hosts. So create the file and then open it for editing.
sudo touch /etc/apache2/sites-available/trac sudo nano /etc/apache2/sites-available/trac
Now the following site configuration will vary from person to person, the referenced guide at the start of this tutorial will show you more advanced features like self signed certificates for ssl rather than authenticating in plain text like the configuration below.
NameVirtualHost trac.yourdomain.com
<VirtualHost trac.yourdomain.com:*>
ServerAdmin adm...@yourdomain.com
DocumentRoot /var/sites/trac.yourdomain.com
DirectoryIndex Index.html
ServerName trac.yourdomain.com
ServerSignature Off
ErrorLog /var/log/apache2/trac_error_log
TransferLog /var/log/apache2/trac_access_log
<Directory "/var/sites/trac.yourdomain.com">
Options +Indexes +MultiViews
Order allow,deny
Allow from all
</Directory>
<Location />
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonInterpreter main_interpreter
PythonOption TracEnv /var/sites/trac.yourdomain.com/
PythonOption TracUriRoot /
AuthType Basic
AuthName "Trac"
# Use the SVN password file.
AuthUserFile /etc/subversion/passwd
Require valid-user
</Location>
</VirtualHost>
The Auth User File for subversion is generated when setting up the repos, which will be included in another guide.
Save and close the file (Ctrl + O and then Ctrl + X). Now before we start the new site we need to compile a python module (clearsilver) for python 2.5 as this is broken in hardy 64 bit. You will need the compilation tools installed and the required dependencies, which is just a single command.
sudo apt-get install build-essential zlib1g-dev python-dev autoconf build-dep python-clearsilver
Now download the latest version and extract the compressed file into a directory.
wget http://www.clearsilver.net/downloads/clearsilver-0.10.5.tar.gz tar zxvf clearsilver-0.10.5.tar.gz
Now we need to edit the configure scripts for compiling the module to allow it to build for python 2.5 so using our favourite text editor nano do the following:
nano clearsilver-0.10.5/configure.in
Now press Ctrl + W and type ‘python_versions’ and press enter.
Change the line to be the following
python_versions="2.5 2.4 2.3 2.2 2.1 2.0 1.5 24 23 22 21 20 15"
Save and close the file. Now we repeat the process with the configure file
nano clearsilver-0.10.5/configure
press Ctrl + W and type ‘python_versions’ and press enter.
Change the line to be the following
python_versions="2.5 2.4 2.3 2.2 2.1 2.0 1.5 24 23 22 21 20 15"
and Save and close the file. You can now build and install the module by doing the following
./configure make sudo make install
Now we need to copy the module binary into the python directory to replace the broken one.
sudo cp -bi python/neo_cgi.so /usr/lib/python2.5/site-packages/neo_cgi.so
Enable the trac site in apache.
sudo a2ensite trac
Now you can start the site up by either restarting or reloading apache
sudo /etc/init.d/apache2 reload
OR
sudo /etc/init.d/apache2 restart
Now surf up trac.yourdomain.com enter the user name and password (if you have set this up) and away you go!
Anyway I hope this is of some help to someone.
Special thanks to fluffypixies for the guide on fixing the python problem which can be found here.
