Skip to content

Home > GNU/Linux > How to deploy recent django on an old Ubuntu Lucid Lynx installation

How to deploy recent django on an old Ubuntu Lucid Lynx installation

Get the correct python version !

Thursday 18 June 2015, by Stéphane Téletchéa

Nowadays it is sometimes difficult to upgrade a wroking web server, when multiple services are installed. In order to keep up with some recent versions, here is a short guide to get django 1.8.1 working with Ubuntu Lucid Lynx and apache 2.2.

In order to ensure the compability between the development server (Ubuntu 14.04 LTS 64 bits) and the production server, we have to compile python first. We will not require super-user powers to install most of the applications :-)

Install latest python version

tar -Jxf Python-2.7.10.tar.xz
cd /Python-2.7.10
./configure —enable-shared —prefix=DESTINATION/python2.7.10/
make install

Remark: replace DESTINATION with your home directory or any directory where you have write access.

Recompile mod_wsgi

cd /mod_wsgi-stable-3.X
export LD_RUN_PATH=DESTINATION/python2.7.10/lib/
export LD_LIBRARY_PATH=DESTINATION/python2.7.10/lib/
./configure —with-python=DESTINATION/python2.7.10/bin/python2.7

Remark: both LD_RUN_PATH and LD_LIBRARY_PATH are mandatory otherwise the compilation and/or the execution within apache will fail.

Ensure the library is properly compiled with the correct python version:

ldd .libs/ =>  (0x00007ffffa3ff000) => DESTINATION/python2.7.10/lib/ (0x00007facf1790000) => /lib/ (0x00007facf156a000) => /lib/ (0x00007facf1365000) => /lib/ (0x00007facf1162000) => /lib/ (0x00007facf0edf000) => /lib/ (0x00007facf0b55000)
        /lib64/ (0x00007facf1d99000)

Remove old apache modules before installing the new one

apt-get remove —purge libapache2-mod-wsgi libapache2-mod-python

Remark: you have to remove both mod-wsgi and mod-python since mod-wsgi supersedes mod-python, ans apache can not handle two different python versions while running (you may run into trouble).

Install the new mod_wsgi and restart apache

Only for these steps, you need to be root (or ask the root to do so).

cd DESTINATION/mod_wsgi-stable-3.X
make install

Then activate the new wsgi apache module, and restart apache:

a2enmod wsgi
service apache2 restart

Remark: You HAVE TO restart apache, a simple reload will not be sufficient to have running modules removed or replaced.

If everything worked properly, you can see in apache2/error.log the python2.7.10 indicated:


Apache/2.2.14 (Ubuntu) mod_python/3.3.1 Python/2.6.5 ... mod_wsgi/3.5 ...


Apache/2.2.14 (Ubuntu) mod_wsgi/3.5 Python/2.7.10 ...

Install latest django with virtualenv

Install lastest virtualenv

virtualenv 1_old_venv —no-site-packages
source 1_old_venv/bin/activate
pip install —upgrade virtualenv

Install lastest a new virtualenv with latest python

source 1_old_venv/bin/activate
virtualenv —python=DESTINATION/python2.7.10/bin/python django1.8 —no-site-packages
source django1.8/bin/activate

Then proceed to install all your requirements

(django1.8) pip install Django==1.8.1
(django1.8) pip install django-extension==1.5.2
(django1.8) pip install MySQL-python==1.2.5

You have now a fully functional django module that you can incoporate into you existing apache configuration using WSGIDaemonProcess.

Useful informations

Comment on this article