The following are notes on how to install and configure trac on OS X with multiple projects with a dedicated user to maintain the trac installation. These notes have been derived from several sources and are primarily so I can reproduce this at a later date without thinking, they are, unsurprisingly
- http://trac.edgewall.org/
- http://modpython.org/
You'll need the following
- sudo / root access
- internet access
- python 2.3.5
- sqlite3
You will need to download
- Apache 2.2.4
- Mod_python 3.3.1
- setuptools
- Install Apache 2.2.4
- Follow Richard's instructions, see step 6 for an overview
./configure --prefix=/Users/jono/Applications/apache/2.2.4 --enable-mods-shared=most --enable-ssl --with-mpm=worker --without-berkeley-db --enable-proxy
check there is something sane here http://127.0.0.1/
make
sudo make install
cd ~/apache/2.2.4/bin
sudo ./apachectrl start
- Follow Richard's instructions, see step 6 for an overview
- Install mod_python 3.3.1
- configure and install
./configure --with-apxs=/Users/jono/Applications/apache/2.2.4/bin/apxs
make
sudo make install tell apache about it
add
LoadModule python_module /Users/jono/Applications/apache/2.2.4/modules/mod_python.so
to
/Users/jono/Applications/apache/2.2.4/conf/httpd.conf
test apache is talking to python
- edit
httpd.confadd
<Location /mpinfo>
SetHandler mod_python
PythonHandler mod_python.testhandler
</Location> restart apache and see what we get
cd ~/apache/2.2.4/bin
sudo ./apachectrl
http://127.0.0.1/mpinfoyou should get a table showing various System information about apache, python and the request headers, including who the process is running as. In our case it is daemon - make a note of this you'll need it later.
clean up
remove the following from
<Location /mpinfo>httpd.conf
SetHandler mod_python
PythonHandler mod_python.testhandler
</Location>
- edit
- configure and install
- Install python modules required by the latest version of trac ( 0.11)
- install setuptools
- this will need to be done as root so you have write permissions to
/System/Library/Frameworks/Python.framework/Versions/2.3/bin
sudo python ez_setup.py
link it to a bin directory in your path - This should be a single line!
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.3/bin/easy_install easy_install
- test it, type eas and you should get tab completion, well, assuming you are using bash.
- install Genshi
easy_install Genshi
- install pysqlite
- make sure easy_install is going to install the correct version,it should be 2.3.2 or above
easy_install -n pysqlite
- if the above seems okay, install it
easy_install pysqlite
- make sure easy_install is going to install the correct version,it should be 2.3.2 or above
- this will need to be done as root so you have write permissions to
- install setuptools
- Install trac
This is some what more convoluted than it needs to be, once edgewall release a complete version (0.11) of trac, this will be
easy_install tracHowever at present this installs 10.4, which is not what we want, so it is worth trying
easy_install -n tracto see if it is going to install 0.11, until then, there is :- check out the latest code from svn, in my case this was revision 6049.
svn co http://svn.edgewall.org/repos/trac/trunk trac - install trac
sudo python ./setup.py install - link the trac binaries to a bin directory in your path.
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.3/bin/ trac-admin trac-admin
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.3/bin/ tracd tracd - If you want to be sure trac is installed and working before continuing ( probably a good idea ) check the Observations notes below.
- check out the latest code from svn, in my case this was revision 6049.
- set up trac user and environment
- create a trac user - see my previous post
- add them to the daemon group - or whatever user apache is running at
sudo nicl / -merge /groups/daemon users daemon - as the trac user create the projects and set the correct permissions
- create projects
trac-admin project00 initenv
trac-admin project01 initenv
- set the permissions on the trac projects
chown -R :daemon project00
chown -R :daemon project01
chmod -R g+rw project00
chmod -R g+rw project01
- create projects
- create a trac user - see my previous post
Configure apache to talk to trac via mod_python
- add the following to httpd.conf
<Location /trac>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /Users/trac
PythonOption TracUriRoot /trac
</Location><LocationMatch "/trac/[^/]+/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /Users/trac/.htpasswd
Require valid-user
</LocationMatch>
- as the trac user populate .htpasswd
htpasswd -c /Users/trac/.htpasswd jono - as the trac user configure trac permissions
- add an administrative user for the projects
trac-admin /Users/trac/project00 permission add jono TRAC_ADMINtrac-admin /Users/trac/project01 permission add jono TRAC_ADMIN
- remove anonymous and authenticated permissions from all projects, this is needed so users can not log into projects others than there own and is probably just a good idea ;)
trac-admin /Users/trac/project00 permission remove anonymous '*'trac-admin /Users/trac/project00 permission remove authenticated '*'
trac-admin /Users/trac/project11 permission remove anonymous '*'trac-admin /Users/trac/project11 permission remove authenticated '*'
- bounce apache
sudo ./apachectl stopsudo ./apachectl start
- try and login
http://127.0.0.1/trac/project0http://127.0.0.1/trac/project1
- add an administrative user for the projects
- add the following to httpd.conf
- restrict access to projects - currently every entry into .htpasswd has access to all projects, as an authenicated user, which would allow users from one project to browse and edit the wiki or another - not an ideal situation, so we do the following
- remove ability to see project listing - what people can't see they can't try and access
- update httpd.conf - change
Locaitonfrom <Location /trac>to <LocationMatch "/.+/">remembering to also update the closing Location tag to LocationMatch - bounce apache
sudo ./apachectl stopsudo ./apachectl start
- update httpd.conf - change
- remove ability to see project listing - what people can't see they can't try and access
- get svn access working
- consider https
- consider using digest rather than basic athenication
- virtual hosts
- install using the default locations for python, installing with user specific locations will cause a great deal of pain, if you know what you are doing with PYTHONPATH, you will probably be okay, then again, you probably aren't going to be reading this either :)
- if you ignored me and tried installing setuptools without root access you will have noticed the binary failed to install and now you are wondering how to get it installed.
sudo python ez_setup.py -U setuptools - restarting apache,there are notes on either the trac or mod_python site about this, it would appear that
sudo ./apachectl restartdoesn’t always work, this is usually when you are tired and it has been working all day, save yourself pain just use.
sudo ./apachectl stop
sudo ./apachectl start if trac isn’t playing you may want to make sure it is installed correctly, try the following
- create a dummy project
trac-admin testTrac initenv
- start the trac daemon
tracd --port 8000 /Users/jono/Documents/trac/testTrac
- point a browser to
http://localhost:8000/testTrac
- if it all looks okay, you can delete this now
- create a dummy project
Finally
Things to do:
Links
Observations
Labels: OSX trac mod_python


0 Comments:
Post a Comment
<< Home