Trac is an open source wiki, subversion interface and issue-tracking system for software development projects. “Our mission is to help developers write great software while staying out of the way,” say the Trac developers. Trac’s wiki markup enables you to seamlessly integrate bugs, tasks, changesets, files and wiki pages.
If you are working on a software project, you want Trac. Trac keeps your code, your bugs, your documentation and other important data all in one place. You can demo Trac here if you’re not yet convinced.
Fortunately, Trac is dead easy to set up on FreeBSD as it’s in ports and doesn’t require much configuration.
Requirements
In order to complete this Trac install, you will need the following:
- A FreeBSD server, computer or VPS where you have root access and that is connected to the internet.
- sshd must be running on the FreeBSD server.
- A personal computer able to connect to your FreeBSD server via ssh.
- Comfort working with the command line interface.
- An Apache 2.0 server or similar already running.
- A fully qualified domain whose A record in DNS points to your FreeBSD server, such as mydomain.com or trac.mydomain.com.
- Approximately 15-30 minutes.
Install Trac from FreeBSD Ports
First we need to find the Trac port.
root@16 ~ # whereis trac
trac: /usr/ports/japanese/trac
Oops, that didn’t work! You could try searching ports but that rarely works well. The easiest option might be to search freshports.org where we’ll find that Trac is at www/trac.
Let’s cd to the trac port directory and install it.
root@16 ~ # cd /usr/ports/www/trac
root@16 /usr/ports/www/trac # make install clean
You’ll get a blue config options dialog here most likely with Silvercity, Docutils and Subversion already selected. I recommend you accept these options so just hit your “o” (as in Oscar) key to proceed. FreeBSD will now download and install all the dependencies. This could take 5-10 minutes. Assuming you were successful you should see a message like this near the end of the output.
Thank you for choosing Trac 0.10.4. Enjoy your stay!
Creating a Trac Instance
Once Trac is installed, we need to create your Trac instance. I like to put my web apps in /usr/local/www so I’ll create my Trac instance at /usr/local/www/trac.
root@16 ~ # trac-admin /usr/local/www/trac initenv
This will prompt you for several variables. If you aren’t sure how to answer, just accept the default. If you already have a subversion repository that you want to be able to view in Trac, you should provide the path to it when this prompt comes up.
Path to repository [/path/to/repos]>
Upon success, you’ll see a message like this.
Project environment for ‘RunningFreeBSD Trac’ created.
You may now configure the environment by editing the file:
/usr/local/www/trac/conf/trac.ini
…
The latest documentation can also always be found on the project
website:http://trac.edgewall.org/
Congratulations!
Apache and Mod_python
This howto assumes you’ll run Trac via Apache (running as user www) so you will need to give user www write permission to trac’s db directory. If you don’t do this you will get a “500 Internal Server Error” when you try to view Trac in your browser (a lesson learned the hard way).
chown -R www /usr/local/www/trac/db
Mod_python is a fast and reliable way to run Python apps, so let’s install it. I already have the apache-2.0.61_2 port installed on my jail (www/apache20 port), so if you don’t you may want to install it before working on mod_python3.
root@16 ~ # whereis mod_python3
mod_python3: /usr/ports/www/mod_python3
root@16 ~ # cd /usr/ports/www/mod_python3
root@16 /usr/ports/www/mod_python3 # make install clean
At the time of publication, the mod_python3 port still doesn’t inject its LoadModule line into httpd.conf, so you will have to do that manually. Open up /usr/local/etc/apache2/httpd.conf (assuming you are using Apache 2.0) in your favorite editor and find the last “LoadModule” line. Below it, add the following (all on one line).
LoadModule python_module /usr/local/libexec/apache2/mod_python.so
Now you can add the Trac VirtualHost stanza to Apache. I like to keep my VirtualHosts separate from httpd.conf but you can add yours to the httpd.conf file temporarily if need be. Be sure to replace ‘trac.runningfreebsd.com’ with your domain.
<VirtualHost *:80>
ServerName trac.runningfreebsd.com
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /usr/local/www/trac
PythonOption TracUriRoot /
SetEnv PYTHON_EGG_CACHE /usr/local/www/trac/.python-eggs
Alias /chrome/common /usr/local/share/trac/htdocs
<Directory "/usr/local/share/trac/htdocs">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location "/">
AuthType Basic
AuthName "Trac"
AuthUserFile /usr/local/etc/apache2/trac.pwd
Require valid-user
</Location>
</VirtualHost>
This config includes password protection for your Trac instance. If you don’t want that you can just remove the following part.
<Location "/">
AuthType Basic
AuthName "Trac"
AuthUserFile /usr/local/etc/apache2/trac.pwd
Require valid-user
</Location>
If you decide to go with password protection, your passwords file is /usr/local/etc/apache2/trac.pwd, which you can create as follows.
root@16 ~ # htpasswd -c /usr/local/etc/apache2/trac.pwd admin
New password:
Re-type new password:
Adding password for user admin
This creates a user ‘admin’ and prompts you to enter the user’s password twice.
Trac Setup Success
Now you can restart Apache and bring up Trac in your browser.
root@16 ~ # apachectl restart
If it worked Trac will give you a “Welcome to Trac 0.10.4″ page in your browser and show you logged in as user admin.
How did it Go?
Did you meet with success? Run into any problems? Let me know in the comments section below.
Related Links
Technorati Tags: trac, wiki, subversion, freebsd, ports, sshd, apache, freshports, mod_python, VirtualHost, htpasswd






12 responses so far ↓
1 shadowbq // Feb 15, 2008 at 2:55 pm
Since the current build is 10.* trac
Install webadmin (now core in 11.* trac)
www/trac-webadmin*
after this is installed
sudo chown www /usr/local/www/trac/conf/trac.ini
This helps with management of trac-admin command
(Report comment)
2 Nazar // Mar 1, 2008 at 4:02 pm
I referenced this post to install Trac on FreeBSD 7.0 and everything worked well. Thanks again.
(Report comment)
3 Ricardo // Apr 29, 2008 at 2:57 am
¡Excellent tutorial!
I implemented everything in my organization in only one day, everything worked.
Used:
1) FreeBSD 7.0 - i386 under VMWare Fusion in a MacBook Pro Intel Box
2) Apache 2.0
3) Trac 0.10.4
4) PostgreSQL 8.1
5) ZSH as the shell
Thank you very very much
(Report comment)
4 George // Apr 29, 2008 at 7:30 am
Excellent, glad to hear it worked for you.
(Report comment)
5 Shyam Prasad Kumpati // May 5, 2008 at 9:18 am
Hi,
I set up everything as mentioned above. However, I get the below error when I try to access trac using a browser.
‘Internal Server Error
The The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.’
(Report comment)
6 George // May 5, 2008 at 9:27 am
What does the error log say? tail it, then try to access the trac site, and see what the error log spits out. Then post it here and I will take a look.
hth
(Report comment)
7 Shyam Prasad Kumpati // May 5, 2008 at 9:43 am
Hi George,
Thanks a lot for quick response. Below is the error I could get from the log file.
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/mod_python/importer.py”, line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/mod_python/importer.py”, line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/mod_python/importer.py”, line 1128, in _execute_target\n result = object(arg)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/web/modpython_frontend.py”, line 87, in handler\n gateway.run(dispatch_request)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/web/wsgi.py”, line 87, in run\n response = application(self.environ, self._start_response)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/web/main.py”, line 391, in dispatch_request\n env = _open_environment(env_path, run_once=run_once)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/web/main.py”, line 58, in _open_environment\n env_cache[env_path] = open_environment(env_path)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/env.py”, line 462, in open_environment\n env = Environment(env_path)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/env.py”, line 139, in __init__\n self.setup_log()
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/env.py”, line 297, in setup_log\n format=format)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/site-packages/trac/log.py”, line 27, in logger_factory\n hdlr = logging.FileHandler(logfile)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] File “/usr/local/lib/python2.5/logging/__init__.py”, line 770, in __init__\n stream = open(filename, mode)
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] IOError: [Errno 13] Permission denied: u’/usr/home/trac/sso-trac/log/trac.log’
Please let me know if can find something.
Thanks,
Shyam
(Report comment)
8 Shyam Prasad Kumpati // May 5, 2008 at 9:45 am
Hi George,
BTW, I am sorry I didn’t understand what you mean by ‘tail it, then try to access the trac site..’. I am a novice to Trac and FreeBSD:-(. So, please bear with me.
Thanks,
Shyam
(Report comment)
9 George // May 5, 2008 at 9:47 am
Here is the error:
[Mon May 05 17:43:44 2008] [error] [client 192.168.26.1] IOError: [Errno 13] Permission denied: u’/usr/home/trac/sso-trac/log/trac.log’
Assuming you are running apache as user www (the default), run this command as root:
chown -R www /path/to/trac
or just chown www /usr/home/trac/sso-trac/log/trac.log if you want to be conservative.
(Report comment)
10 Shyam Prasad Kumpati // May 5, 2008 at 11:58 am
Wow! It works after doing little bit of modifications. Many many thanks, George.
BTW, I am going through your flkr photos and I should say I am enjoying seeing your photos!
Thanks again and have a good day!
Regards,
Shyam
(Report comment)
11 Shyam Prasad K // May 9, 2008 at 4:44 am
Hi,
I set up Trac on FreeBSD. It works fine, but when I click on ‘Login’ link, it gives me the following error:
*******************************************
500 Internal Server Error (Authentication information not available. Please refer to the installation documentation.)
*******************************************
When I look at the trac.log, this is what I see.
*******************************************
2008-05-09 15:08:33,199 Trac[macros] ERROR: Failed to load wiki macro MimeInclude.py (No module named WikiFormatter)
Traceback (most recent call last):
File “/usr/local/lib/python2.5/site-packages/trac/wiki/macros.py”, line 443, in get_macros
module = self._load_macro(filename[:-3])
File “/usr/local/lib/python2.5/site-packages/trac/wiki/macros.py”, line 468, in _load_macro
return imp.load_source(name, macro_file)
File “/usr/home/trac/sso-trac/wiki-macros/MimeInclude.py”, line 52, in
from trac.WikiFormatter import wiki_to_html
ImportError: No module named WikiFormatter
2008-05-09 15:08:33,200 Trac[macros] ERROR: Failed to load wiki macro Blog.py (No module named WikiFormatter)
Traceback (most recent call last):
File “/usr/local/lib/python2.5/site-packages/trac/wiki/macros.py”, line 443, in get_macros
module = self._load_macro(filename[:-3])
File “/usr/local/lib/python2.5/site-packages/trac/wiki/macros.py”, line 468, in _load_macro
return imp.load_source(name, macro_file)
File “/usr/home/trac/sso-trac/wiki-macros/Blog.py”, line 13, in
from trac.WikiFormatter import *
ImportError: No module named WikiFormatter
2008-05-09 15:10:46,837 Trac[main] WARNING: 500 Internal Server Error (500 Internal Server Error (Authentication information not available. Please refer to the installation documentation.))
*******************************************
Is there any way you can help me please?
Thanks,
Shyam
(Report comment)
12 George // May 10, 2008 at 11:34 am
You made some kind of serious error.
Start over and follow the instructions in the howto to the letter.
(Report comment)
Leave a Comment