Edgewall Software

Version 51 (modified by anonymous, 18 years ago) ( diff )

This page describes three different ways of installing Trac on Mac OS X: by hand, by using Fink, and by using pkgsrc.

Installing By Hand (Without Fink)

If you don't have Fink yet or don't want it, you can build everything yourself from the source tarballs by following the instructions in TracOnOsxNoFink.

Installing With Fink

If you already have Fink and are comfortable using it, you may prefer to install Trac that way. But multiple people have noticed that SQLite currently won't install unless you enable unstable packages in Fink; the same goes for the handy trac-py23 or trac-py24 packages mentioned a little later on.

note: this doesn't seem to be true as of fink 0.8.1.

Warning: If you wish to use pysqlite2/sqlite3 you should either create your trac project after installing pysqlite2-py24 or you will need to hand convert your trac project database from sqlite2 to sqlite3. trac tries to load pysqlite2/sqlite3 in preference to pysqlite/sqlite2. If your database is sqlite2 and you have pysqlite2/sqlite3, you will get errors about your database being unknown or encrypted.

$ mv trac.db trac2.db
$ sqlite trac2.db .dump | sqlite3 trac.db

Updating Fink

It's probably a good idea to start by making sure your Fink base system is the most current:

$ fink selfupdate

When it's done it'll tell you to update the rest of your packages, but I think it's ok to defer that until a little later.

Installing SQLite

You can install SQLite this way:

$ fink install sqlite sqlite-dev sqlite-shlibs

Or, apparently, also this way:

$ apt-get install sqlite sqlite-dev sqlite-shlibs

Though fink manages the administrator/root permissions for you, which might be handy. You probably have to allow fink to use unstable packages. Otherwise it might not be able to find the sqlite package. In FinkCommander→Preferences tick Use unstable packages.

Note: unless you know what you're doing, you're best off using the system version of SQLite, because Apple include extra code in their build to make file locking work better on a variety of filesystems. There is a patch available for SQLite 3.3.6 that adds the necessary code if you really must build SQLite yourself, but the Apple supplied version (presently 3.1.3) should work fine with Trac.

Installing Subversion

Assuming you want Subversion to support secure connections, install it this way:

$ fink install svn-ssl svn-client-ssl svn-ssl-swig-py23

or

$ fink install svn-ssl svn-client-ssl svn-ssl-swig-py24

If you'd rather dispense with the SSL, get the regular versions:

$ fink install svn svn-client svn-swig-py23

or

$ fink install svn svn-client svn-swig-py24

Updating Fink Packages

Now is I think an excellent time to have Fink update the rest of its installed packages:

$ fink update-all

I found that the above fink commands had given me somewhat elderly Subversion 1.0.6 binaries; after updating with Fink to the unstable branch, I got the current (at the time of this writing) 1.2.1-11 version.

Installing Clearsilver, pysqlite, and Trac Itself

It used to be that pysqlite and Clearsilver couldn't be installed using Fink; instructions on how to manually download and install them are below. Since then however a new Fink package has appeared which lets you install these without much fuss:

$ fink install trac-py23

or

$ fink install trac-py24 (for python24 support)

See Troubleshooting note below if using trac-py24

That should be all you need to do. You can now set up your Trac environment as per the usual instructions. If you do end up needing to install pysqlite, Clearsilver and Trac manually after having installed the rest with Fink as above, read on.

Setting up Trac using Apple Personal Webserver

For more a in depth description read TracInstall

To initialize a Trac environment at /path/to/projectenv run the following commands, trac-admin will ask for an existing Subversion repository:

$ trac-admin /path/to/projectenv initenv
$ sudo chown -R www /path/to/projectenv

Please remember to set appropriate permissions for your Subversion repository. (which are? Maybe someone could expand on this?)

Open the Apache configuration file /etc/httpd/httpd.conf for editing:

$ sudo nano -w /etc/httpd/httpd.conf

Add the following to have Trac appear at yourdomain.tld/webpath (with TracPrettyUrls). Change /path/to/projectenv to your particular setup.

     Alias /trac/ /sw/share/trac/htdocs/

     RewriteEngine On

     <Directory "/sw/share/trac/htdocs">
       Options Indexes MultiViews
       AllowOverride None
       Order allow,deny
       Allow from all
     </Directory>

    # You need this to allow users to authenticate
    # trac.htpasswd can be created with
    # cmd 'htpasswd -c trac.htpasswd' (UNIX)
    # do 'man htpasswd' to see all the options
    <Location "/webpath/login">
        AuthType Basic
        AuthName "trac"
        AuthUserFile /path/to/projectenv/conf/trac.htpasswd
        Require valid-user
    </Location>

     SetEnv TRAC_ENV "/path/to/projectenv/"
     ScriptAliasMatch ^/webpath(.*) /sw/share/trac/cgi-bin/trac.cgi$1

Double check that the mod_env is enabled in your config. By default, the config is commented out. This is what you are looking for:

LoadModule env_module         libexec/httpd/mod_env.so
AddModule mod_env.c

Now check if Apache is started, and possibly reload the configuration files:

$ sudo apachectl start
$ sudo apachectl graceful

Your Trac installation should now be available at yourdomain.tld/webpath/

Manually Installing Clearsilver

Download version 0.9.12 of Clearsilver. Compile it with Python support and install it in the Fink prefix.

$ ./configure --prefix=/sw --with-python=/sw/bin/python2.3 --disable-ruby
$ make install

You have to change the hard-coded /usr/local/bin/python path to /sw/bin/python2.3 (or /usr/bin/python if you're using the system Python) on the first line of scripts/document.py when running make install.

Manually Installing pysqlite

The file setup.py in the pysqlite distribution doesn't recognize the Darwin platform so you'll have to add the following lines to setup.py (it should be quite obvious where, but don't put it too late in the list of operating systems it checks):

elif sys.platform == "darwin":
    include_dirs = ['/sw/include/']
    library_dirs = ['/sw/lib/']
    libraries = [sqlite]
    runtime_library_dirs = []

    extra_objects = []

After that modification the installation should simply be:

$ /sw/bin/python2.3 ./setup.py install

Manually Installing Trac Itself

You should now be all set to install Trac using the TracInstall instructions. Make sure to use /sw/bin/python2.3 when running the setup.py script. Most likely, you will also need to add the path to svn-python to your path both when running trac-admin from the command line:

export PYTHONPATH=/usr/local/lib/svn-python/

and in your Apache configuration:

<Location "/cgi-bin/trac.cgi">
   SetEnv PYTHONPATH "/usr/local/lib/svn-python/"
</Location>

An alternative to setting PYTHONPATH is to execute the following from the shell once:

echo /usr/local/lib/svn-python/ > /sw/lib/python2.3/SVN.pth

This will cause /usr/local/lib/svn-python/ to be permanently added to the Python search path.

These instructions were originally written off the top of Jonas Borgstrom's head, and rearranged and rewritten quite a bit by Ryan Schmidt, and probably edited and corrected by many others. If you find errors or omissions, please edit the page and make the corrections. You can also contact Jonas.

I recently installed Trac on an Intel Mac and had a bit of a struggle. I was getting some very annoying ImportError: No module named svn errors. I noticed that some python packages install to /Library/Python/2.3/site-packages/ and some install to sw/lib/python2.3/site-packages. (I guess that's the difference between the manual installations and the Fink installations.) I found that inserting this line into /Library/Pyhton/2.3/site-packages/Extras.pth got everything going:

/sw/lib/python2.3/site-packages

Troubleshooting

CGI

If you have problems getting Apple's personal web sharing (a.k.a. Apache 1.3) to run trac.cgi with the correct python interpreter (/sw/bin/python2.3), you can place this dummy trac.cgi in /Library/WebServer/CGI-Executables/:

#! /bin/sh
/sw/bin/python2.3 /somewhere/cgi-bin/trac.cgi

This is required due to a bug in the way Python locates it's own library directory. It is present in all versions of Python up to 2.3.4, but will be fixed in both 2.4 and 2.3.5. — Mark Rowe

Update your python23 installation if you still need this fix.

$ fink install python23

or:

$ fink rebuild python23

Trac-py24

If using the Fink packages python24, trac-py24 and clearsilver-py24 you may get the error:

 No module named neo_cgi

when using trac-admin or viewing through a web browser, this is because the Fink clearsilver-py24 package does not appear to include its python bindings so do a manual make of Clearsilver from the corresponding source version to the fink version, then copy the python binding to the python lib:

$ cd <source dir>/python
$ sudo cp neo_cgi.so /sw/lib/python2.4/site-packages/

Installing using pkgsrc

As an alternative to Fink and compiling by hand, you can install from pkgsrc, which runs just as well on Mac OS X as it runs on NetBSD or Linux. See TracOnNetBsd for more information.

Note that at least one person couldn't get this method to work at all.

Another alternative to Fink is to use the Darwin Ports packages at http://darwinports.opendarwin.org/ .

Setting up tracd as a launchd service

If you use tracd to locally serve trac projects under Mac OS X Tiger, you can set it up to be automatically launched by way of Tiger's launchd service. I use tracd instead of Apache because I'm only serving trac to myself and I don't want to futz with Apache configuration. See TracOnOsxTracdAsLaunchdService for a receipe of how to set this up.

Using DarwinPorts

Installation steps:

  1. sudo port install apache2
  2. sudo port install subversion +mod_dav_svn
  3. sudo port install mod_python
  4. sudo port install trac

Now if you get an error like this:

--->  Installing subversion 1.3.0_2+mod_dav_svn
--->  Activating subversion 1.3.0_2+mod_dav_svn
Error: Target com.apple.activate returned: Image error: Another version of subversion (1.3.0_2) is already active.
Error: /opt/local/bin/port: Status 1 encountered during processing.

Well try uninstalling subversion:

  1. sudo port uninstall trac
  2. sudo port uninstall subversion-pythonbindings
  3. sudo port uninstall subversion @1.3.0_2
  4. sudo port install subversion +mod_dav_svn
  5. sudo port install mod_python
  6. sudo port install trac

Then on to:

Here is the trac configuration from my httpd.conf

<VirtualHost *>
        ServerName projects.<domain>.com
        DocumentRoot "/Projects/Trac"

         #
         # Trac mod_python configuration
         #
         Alias /trachtdocs/ "/opt/local/share/trac/htdocs/"
         <Location /trac>
                 SetHandler mod_python
                 #PythonHandler trac.ModPythonHandler
                 PythonHandler trac.web.modpython_frontend
                 PythonOption TracUriRoot "/trac"
                 PythonOption TracEnvParentDir "/Projects/Trac"
         </Location>

         <LocationMatch /trac/[[:alnum:]]+/login>
                 AuthType Basic
                 AuthName "Trac"
                 AuthUserFile "/opt/local/etc/trac-auth-file"
                 Require valid-user
         </LocationMatch>
</VirtualHost>
Note: See TracWiki for help on using the wiki.