This is how I got Mercurial up and running on CentOS 5.5 x64. The goal here was to deploy this as a “central” repository Mercurial server so the dev team can push their updates to this box.
For this build I used:
First off download all of the files listed above to
cd /usr/local/src wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz wget http://www.sqlite.org/sqlite-autoconf-3070800.tar.gz wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz wget http://prdownloads.sourceforge.net/docutils/docutils-0.8.1.tar.gz wget http://mercurial.selenic.com/release/mercurial-1.9.3.tar.gz tar zxf Python-2.7.2.tgz tar zxf sqlite-autoconf-3070800.tar.gz tar zxf mod_wsgi-3.3.tar.gz tar zxf docutils-0.8.1.tar.gz tar zxf mercurial-1.9.3.tar.gz
There are a few dependencies we’ll need, some might already be installed:
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel make
Build and install SQLite3:
cd sqlite-autoconf-3070800 ./configure make make install cd ..
CentOS 5.5 ships with Python 2.4 which is fine for Mercurial but I wanted to use Python 2.7 for some other stuff as well. This explains how to install Python 2.7 side by side with 2.4 (which would be a real bugger to evict from your system due to the huge number of dependencies there are – yum for example).
I installed Python 2.7 into
/opt/python2.7.2, to do this:
cd Python-2.7.2 ./configure --prefix=/opt/python2.7.2 --with-threads --enable-shared make make install cd ..
When you execute
make it’s possible you’ll get this message:
Python build finished, but the necessary bits to build these modules were not found:
bsddb185 dl imageop
Don’t worry, Python was built successfully, it just means these modules aren’t supported. For our purposes it won’t break anything not to have these modules, they are either deprecated or not relevant.
Next we need to tell
ld where to find our Python 2.7 shared libraries:
touch /etc/ld.so.conf.d/opt-python2.7.2.conf echo "/opt/python2.7.2/lib/" >> /etc/ld.so.conf.d/opt-python2.7.2.conf ldconfig
Then we create a link to Python 2.7 in
/usr/bin and fix up our bash profile to use 2.7:
ln -sf /opt/python2.7.2/bin/python /usr/bin/python2.7 echo "alias python=/opt/python2.7.2/bin/python" >> ~/.bash_profile echo "alias python2.7=/opt/python2.7.2/bin/python" >> ~/.bash_profile echo "PATH=$PATH:/opt/python2.7.2/bin" >> ~/.bash_profile source ~/.bash_profile
If all is well you should see the following when you launch
Python 2.7.2 (default, Oct 21 2011, 10:46:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Press Ctrl+D to exit back to bash.
PyPi, pip, virtualenv (optional)
Although not strictly necessary I also installed these to flesh out my Python dev environment:
cd /usr/local/src sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7.2 /opt/python2.7.2/bin/easy_install pip ln -sf /opt/python2.7.2/bin/pip /usr/bin/pip pip install virtualenv ln -sf /opt/python2.7.2/bin/virtualenv /usr/bin/virtualenv
Mercurial requires Docutils. When installed this for the first time I had to explicitly call python 2.7 to ensure that Docutils was installed to
/opt/python2.7 and not the default Python 2.4 install (that said it’s no big deal if it does also end up being installed there):
cd docutils-0.8.1 python2.7 setup.py install cd ..
Drop into the mercuria source directory:
Build and install Mercurial:
make PYTHON=/opt/python2.7.2/bin/python PREFIX=/opt/python2.7.2 all make PYTHON=/opt/python2.7.2/bin/python PREFIX=/opt/python2.7.2 install cd ..
Pay particular attention to the
PREFIX=/opt/python2.7.2 arguments, these ensure that mercurial is built using our Python 2.7 install and gets installed in the correct
hg version and hit return, if all is good you should see:
Mercurial Distributed SCM (version 1.9.3)
(see http://mercurial.selenic.com for more information)
Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
To build mod_wsgi you need to ensure that the
httpd-devel package is installed, I’m assuming you already have apache installed, so go ahead and do that now:
yum install httpd-devel
Next we do the build, and be sure to configure for Python 2.7:
cd mod_wsgi-3.3 ./configure --with-python=/opt/python2.7.2/bin/python make make install
If all is good then you’ll find
mod_wsgi.so in your apache modules folder:
$ ll /usr/lib/httpd/modules/mod_wsgi.so -rwxr-xr-x 1 root root 303801 Oct 21 12:12 /usr/lib/httpd/modules/mod_wsgi.so
Continued in Part #2…