How to install InDefero on a shared server like Dreamhost, using Mercurial
InDefero on Dreamhost with Mercurial
This little how-to explains how to get InDefero and the Mercurial SCM to work on a shared server environment like Dreamhost.
It involves creating a local PEAR install, a local Mercurial install and tweaking the InDefero and Pluf installation to work with that particular setup.
Details
1. Mercurial
Get and compile
More often than not, your hosting provider has installed an old version of Mercurial.
Dreamhost only carries Mercurial 0.9, which is ancient.
We need the latest version.
Enter hg version in your ssh shell.
If it's old, we need to compile it ourselves:
$ mkdir -p ~/.packages/src
$ cd ~/.packages/src
$ wget http://www.selenic.com/mercurial/release/mercurial-1.3.1.tar.gz
$ tar xvzf mercurial-1.3.1.tar.gz
$ cd mercurial-1.3.1
$ python setup.py install --home=~/.packages/
Notice that we are doing a local install by passing --home to the install script.
Edit .bashrc and .bash_profile (round one)
Put these lines in both .bashrc and .bash_profile:
export PYTHONPATH=${HOME}/.packages/lib/python
export PATH=${HOME}/.packages/bin:$PATH
Log out or reload your environment - enter hg version
It should print:
$ Mercurial Distributed SCM (version 1.3.1)
Further reading
You probably need to setup serving of hgweb.
The reason why it's not in this guide is that it's a fairly standard procedure.
See this link for instructions:
Mercurial page on Dreamhost Wiki
2. PEAR
Run the following commands in your shell:
Create your local pear config:
$ pear config-create $HOME .pearrc
Set up pear tmp directories (replace
$ pear config-set download_dir /home/<username>/tmp/pear/cache
$ pear config-set cache_dir /home/<username>/tmp/pear/cache
$ pear config-set temp_dir /home/<username>/tmp/pear/temp
Install your very own local copy of PEAR:
$ pear install -o PEAR
Edit .bashrc and .bash_profile (round two)
Add these two lines to your .bashrc and .bash_profile:
export PHP_PEAR_PHP_BIN=/usr/local/php5/bin/php
export PATH=/home/username/pear:/usr/local/php5/bin:$PATH
Please replace username with your own username - easy to overlook.
Reload your environment.
Install Mail and Mail_Mime packages
(Taken straight off of the standard InDefero install instructions)
$ pear upgrade-all
$ pear install --alldeps Mail
$ pear install --alldeps Mail_mime
Check your environment by entering the following into the shell:
$ pear list
If all is well, you should see this:
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.3 stable
Auth_SASL 1.0.3 stable
Console_Getopt 1.2.3 stable
Mail 1.1.14 stable
Mail_Mime 1.5.2 stable
Mail_mimeDecode 1.5.0 stable
Net_SMTP 1.3.3 stable
Net_Socket 1.0.9 stable
PEAR 1.9.0 stable
Structures_Graph 1.0.2 stable
XML_Util 1.2.1 stable
3. Tweaking Pluf and InDefero sources
Besides following the standard installation instructions, you need to tweak some configuration options and edit some source files in order to successfully install it.
You need to do this before running the migrate script!
indefero/src/conf/idf.php
Make sure that you are setting hg_path to your local hg:
$cfg['hg_path'] = '/home/<username>/bin/hg';
pluf/src/Migrate.php
Put these lines at the start of the file:
$pear_path_local = '/home/<username>/pear/php';
set_include_path($pear_path_local
.PATH_SEPARATOR.get_include_path());
It should silent PEAR errors when running the migrate script.
indefero/www/index.php
Edit the index.php file:
// Set the include path to have Pluf and IDF in it.
// Ensure that we use the right Python path:
putenv('PYTHONPATH=/home/<username>/.packages/lib/python');
// Provide local PEAR path:
$pear_path_local = '/home/<username>/pear/php';
// Can't hurt to pass local PEAR config:
$pear_user_config = '/home/<username>/.pearrc';
$indefero_path = '/home/<username>/<path_to>/indefero/src';
$pluf_path = '/home/<username>/<path_to>/pluf/src';
// Local PEAR path must before global include path:
set_include_path($pear_path_local
.PATH_SEPARATOR.get_include_path()
.PATH_SEPARATOR.$indefero_path
.PATH_SEPARATOR.$pluf_path
);
require 'Pluf.php';
Important :
Setting the PYTHONPATH is crucial because otherwise the script tries to load the global Python libs instead of the local libs, and our local Mercurial silently fails.
Putting the local pear path before the global include path is also all-important.
That's it ! :)
This would not have been solved if it wasn't for meister_ on IRC.
A huge thanks to him for his assistance. :)
( See Issue 294 for reference )