The more than complete "Mercurial and Trac setup" howto for bluehost

This page is now somewhat deprecated, as we now use Mercurial and Redmine.

The setup here should still work OK, but I’ve made a new howto on Mercurial/Redmine setup
here

As the guides I’ve found aren’t quite up to date, here’s how I did it.
The versions used for all software isn’t always the latest version, but these versions work with this setup.
commands to run directly from the prompt is in this format
text to enter in files etc is in this format
Text you need to change is in the format

Before you start:
1.

update bash_profile and add/modify these 3 lines
nano ~/.bash_profile
export LD_LIBRARY_PATH=”$HOME/packages/lib:$LD_LIBRARY_PATH”
export PYTHONPATH=”$HOME/packages/lib/python2.3/site-packages:$PYTHONPATH”
export PATH=”$HOME/packages/bin:$HOME/bin:$PATH”

source ~/.bash_profile
nano ~/.bashrc
PATH=$PATH:$HOME/bin:$HOME/packages/mercurial

source ~/.bashrc
2. create folders
cd
mkdir install_files
mkdir packages
mkdir trac_sites
mkdir ~/public_html/hg
mkdir ~/public_html/hg/repos
mkdir ~/public_html/trac
mkdir ~/public_html/trac/PROJECT

Mercurial installation:

1.Get mercurial and install
cd ~/packages
wget http://www.selenic.com/mercurial-stable-snapshot.tar.gz
tar zxf mercurial-stable-snapshot.tar.gz
mv mercurial-stable-snapshot.tar.gz ~/install_files/
mv mercurial* mercurial
cd mercurial
make local
./hg debuginstall

2. Fix cgi file
cp ~/packages/mercurial/hgwebdir.cgi ~/public_html/hg
chmod 755 ~/public_html/hg/hgwebdir.cgi
sed 's|#import sys|import sys|g' ~/public_html/hg/hgwebdir.cgi > TMPFILE && mv TMPFILE ~/public_html/hg/hgwebdir.cgi
sed 's|#sys.path.insert(0, "/path/to/python/lib")|sys.path.insert(0, "/home/'$USER'/packages/mercurial")|g' \
~/public_html/hg/hgwebdir.cgi > TMPFILE && mv TMPFILE ~/public_html/hg/hgwebdir.cgi

3.

Create hgweb.config file
echo [collections] > ~/public_html/hg/hgweb.config
echo /home/$USER/public_html/hg/repos = /home/$USER/public_html/hg/repos >> ~/public_html/hg/hgweb.config
echo [web] >> ~/public_html/hg/hgweb.config
echo allowpull=true >> ~/public_html/hg/hgweb.config

4. Create .htaccess
echo 'Options +ExecCGI' > ~/public_html/hg/.htaccess
echo 'RewriteEngine On' >> ~/public_html/hg/.htaccess
echo 'RewriteBase /'~$USER'/hg' >> ~/public_html/hg/.htaccess
echo 'RewriteRule ^$ hgwebdir.cgi [L]' >> ~/public_html/hg/.htaccess
echo 'RewriteCond %{REQUEST_FILENAME} !-f' >> ~/public_html/hg/.htaccess
echo 'RewriteCond %{REQUEST_FILENAME} !-d' >> ~/public_html/hg/.htaccess
echo 'RewriteRule (.*) hgwebdir.cgi/$1 [QSA,L]' >> ~/public_html/hg/.htaccess
echo 'AuthUserFile /home/'$USER'/etc/hg-basic-auth' >> ~/public_html/hg/.htaccess
echo 'AuthName "HG Repositories"' >> ~/public_html/hg/.htaccess
echo 'AuthType Basic' >> ~/public_html/hg/.htaccess
echo 'Require valid-user' >> ~/public_html/hg/.htaccess

5. Create password file
cd
htpasswd -b -c -d ~/etc/hg-basic-auth HgUserName PASSWORD

For extra users:
htpasswd -b -d ~/etc/hg-basic-auth HgUserName PASSWORD

6. Initialise repositories
cd ~/public_html/hg/repos
~/packages/mercurial/hg init PROJECT

For extra projects:
~/packages/mercurial/hg init PROJECTn

7. Create hgrc files for each project
echo '[web]' > ~/public_html/hg/repos/PROJECT/.hg/hgrc
echo 'contact=admin email address' >> ~/public_html/hg/repos/PROJECT/.hg/hgrc
echo 'description=My releases' >> ~/public_html/hg/repos/PROJECT/.hg/hgrc
echo 'allow_push=USER1, USERn' >> ~/public_html/hg/repos/PROJECT/.hg/hgrc
echo 'allow_archive=zip' >> ~/public_html/hg/repos/PROJECT/.hg/hgrc

Trac installation

1. Install python (EasyInstall)
cd ~/install_files
wget http://peak.telecommunity.com/dist/virtual-python.py
wget http://peak.telecommunity.com/dist/ez_setup.py
python virtual-python.py --prefix=$HOME/packages
python ez_setup.py --prefix=$HOME/packages

2. Install Subversion (SVN) to get the latest versions of some of the needed software
cd ~/install_files
wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz
wget http://subversion.tigris.org/downloads/subversion-deps-1.4.6.tar.gz
tar -xzf subversion-1.4.6.tar.gz
tar -xzf subversion-deps-1.4.6.tar.gz
cd subversion-1.4.6/apr
./configure --enable-shared --prefix=$HOME/packages
make
make install
cd ../apr-util
./configure --enable-shared --prefix=$HOME/packages --with-expat=builtin --with-apr=$HOME/packages --without-berlekey-db
make
make install
cd ../neon
./configure --enable-shared --prefix=$HOME/packages --with-libs=$HOME/packages --with-ssl
make
make install
cd ../
./configure --prefix=$HOME/packages --without-berlekey-db --with-editor=/usr/bin/vim --with-apr=$HOME/packages \
--with-apr-util=$HOME/packages --with-neon=$HOME/packages --without-apxs --without-apache
make
make install

3. Install Trac (0.10.4) (I’m going to make the 0.11 guide when I get that working)
cd ~/install_files
wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
tar zxf trac-0.10.4.tar.gz
python setup.py build
python ./setup.py install --prefix=$HOME/packages

4. Install Clearsilver (0.10.5)
cd ~/install_files
wget http://www.clearsilver.net/downloads/clearsilver-0.10.5.tar.gz
tar zxf clearsilver-0.10.5.tar.gz
cd clearsilver-0.10.5
sed -i "s@/usr/local/bin/python@/usr/bin/env python@g" scripts/document.py
PYTHON_SITE=`$HOME/packages/bin/python -c "import sys; print [path for path in sys.path if \
path.find('site-packages') != -1][]"` ./configure --with-python=$HOME/packages/bin/python \
--prefix=$HOME/packages --disable-ruby --disable-java --disable-apache --disable-csharp --disable-perl
make
make install

5.Install SQLite (3.5.6) (Check http://www.sqlite.org/ for latest version)
cd ~/install_files
wget http://www.sqlite.org/sqlite-3.5.6.tar.gz
tar zxf sqlite-3.5.6.tar.gz
cd sqlite-3.5.6
./configure --prefix=$HOME/packages --disable-tcl
make
make install
ln -s $HOME/packages/bin/sqlite3 $HOME/packages/bin/sqlite

6. Install PySQLite (2.3.3)
cd ~/install_files
wget http://initd.org/pub/software/pysqlite/releases/2.3/2.3.3/pysqlite-2.3.3.tar.gz
tar zxf pysqlite-2.3.3.tar.gz
cd pysqlite-2.3.3
sed 's|include_dirs = \[\]|include_dirs = \["'$HOME'/packages/include"\]|g' setup.py > TMPFILE && mv TMPFILE setup.py
sed 's|^library_dirs = \[\]|library_dirs = \["'$HOME'/packages/lib"\]|g' setup.py > TMPFILE && mv TMPFILE setup.py
python setup.py build
python setup.py install --prefix=$HOME/packages

7.Install SWIG (latest version)
cd ~/install_files
svn co https://swig.svn.sourceforge.net/svnroot/swig/trunk swig
cd swig
./autogen.sh
./configure --prefix=$HOME/packages --with-python=/usr/bin/python
make
make install

8. Install Trac webadmin module
cd ~/install_files
svn co http://svn.edgewall.com/repos/trac/sandbox/webadmin/ webadmin
cd webadmin
python setup.py egg_info
python setup.py bdist_egg
cd dist
easy_install --prefix=$HOME/packages *.egg

9. Install AccountManager Plugin
cd ~/install_files
svn co http://trac-hacks.org/svn/accountmanagerplugin/0.10 accountmanagerplugin
cd accountmanagerplugin
python setup.py bdist_egg
cd dist
easy_install --prefix=$HOME/packages *.egg

10. Install IniAdmin Plugin
cd ~/install_files
svn co http://trac-hacks.org/svn/iniadminplugin/0.10/ iniadmin
cd iniadmin
python setup.py bdist_egg
cd dist
easy_install --prefix=$HOME/packages *.egg

11. Install TracNav Plugin
cd ~/install_files
svn co http://svn.ipd.uni-karlsruhe.de/repos/javaparty/JP/trac/plugins/tracnav/ tracnav
cd tracnav
python setup.py bdist_egg
cd dist
easy_install --prefix=$HOME/packages *.egg

12. Install Hg (mercurial) plugin
cd ~/install_files
svn co http://svn.edgewall.com/repos/trac/sandbox/mercurial-plugin mercurial-plugin
cd mercurial-plugin
python setup.py bdist_egg
cd dist
easy_install --prefix=$HOME/packages *.egg

13. Trac project initialisation
cd ~/trac_sites
trac-admin ~/trac_sites/PROJECT initenv

You will be asked for
* Project Name: {Whatever you want}
* Database connection string: (just hit return)
* Path to repository: (just hit return)
* Templates directory: (just hit return)

14. Add users to Trac:
trac-admin ~/trac_sites/PROJECT
In the Trac admin prompt, run these commands
permission add admins TRAC_ADMIN
permission add TracUserName admins

For extra users run
permission add TracUserName admins
15. Add a user password (for AccountManager to work, only one needed)
htpasswd -b -c ~/trac_sites/trac.htpasswd TracUserName PASSWORD
16. Setup the Trac web site
cd ~/www/trac/PROJECT
echo '#!/bin/bash' > index.cgi
echo 'export HOME="'$HOME'"' >> index.cgi
echo 'export TRAC_ENV="$HOME/trac_sites/PROJECT"' >> index.cgi
echo 'export PYTHONPATH="$HOME/packages/mercurial:$HOME/packages/lib/python2.3/site-packages"' >> index.cgi
echo 'export PATH="$HOME/packages/bin:$HOME/packages/mercurial:$PATH"' >> index.cgi
echo 'export LD_LIBRARY_PATH="$HOME/packages/lib"' >> index.cgi
echo 'exec $HOME/packages/share/trac/cgi-bin/trac.cgi' >> index.cgi
chmod 755 ~/www/trac/PROJECT/index.cgi

17. Add .htaccess to the project
cd ~/www/trac/PROJECT
echo 'DirectoryIndex index.cgi' > .htaccess

18. Edit trac.ini
cd ~/trac_sites/PROJECT/conf/
sed '1i\node_format = short' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\show_rev = yes' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\\[hg\]' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\password_file = '$HOME'/trac_sites/trac.htpasswd' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\password_format = htpasswd' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\\[account-manager\]' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\tracvc.hg.\* = enabled' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\tracnav.\* = enabled' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\iniadmin.\* = enabled' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\acct_mgr.\* = enabled|g' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\trac.web.auth.LoginModule = disabled' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\webadmin.\* = enabled' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed '1i\\[components\]' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed 's|repository_type = svn|repository_type = hg|' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed 's|repository_dir =|repository_dir = '$HOME'/public_html/hg/repos/PROJECT|g' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed 's|url = http:\/\/example.org\/|url = http:\/\/www.site.com\/trac\/|g' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed 's|link = http:\/\/example.org\/|link = http:\/\/www.site.com\/trac\/|g' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed 's|name = My Project|name = PROJECT Trac|g' trac.ini > TMPFILE && mv TMPFILE trac.ini
sed 's|descr = My example project|descr = Project desc|g' trac.ini > TMPFILE && mv TMPFILE trac.ini

That’s all

6 Responses to The more than complete "Mercurial and Trac setup" howto for bluehost

  1. Léonie says:

    Thanks for this “great how to”.
    On the Mercurial installation on step 5 I keep getting the following error:

    htpasswd: error while loading shared libraries: libaprutil-1.so.0: cannot open shared object file: No such file or directory

    I checked in packages/lib/ and there is no such file. Just the “libaprutil-0.so.0”.

    Any tips for me?
    Thanks in advance, Léonie

  2. Léonie says:

    Also on Trac installation step 4. (Install Clearsilver) on the “make” I get the following error:

    make[1]: Entering directory `/home/myUsername/install_files/clearsilver-0.10.5/cs’
    Running cs regression tests
    Failed Regression Test: test_crc.cs
    See test_crc.cs.out and test_crc.cs.err
    make[1]: *** [test] Error 1
    make[1]: Leaving directory `/home/myUsername/install_files/clearsilver-0.10.5/cs’

    content of test_crc.cs.out:
    ——————-
    Parsing test_crc.cs
    419156592
    1357503972
    2166050276
    ——————-

    content of test_crc.cs.err
    ——————-
    4c4
    2166050276
    ——————-

    What could this mean?
    Léonie.

  3. magnes says:

    Léonie: For the htpasswd error, try step 5 again after step 2 of Trac installation.
    The aprutil is built there.
    For the Clearsilver error, this I’ll have to try to reproduce and I will post my findings here.

    I am going to do an upgrade of our Hg/Trac installation here pretty soon, and will then make a guide on how to do that as well. (And hopefully I’ll get the errors you got so I can investigate a bit.)

    Magne

  4. YahooBot says:

    Nice site, thanks for information!

  5. HairyMan says:

    Not bad… Not bad.

Comments are closed.