This can be a lengthy question detailing everything Used to do from the beginning. Hope it will help. I'm focusing on a django application and want to deploy it onto the development server. The development server is really a virtual server handled because of it, and I don't possess the root access. They've given me privileges to handle the installations of my modules in /swadm and /home/swadm. And So I have planned to complete produce the following arrangement:

  • /swadm/etc/httpd/conf where I maintain httpd.conf
  • /swadm/etc/httpd/user-modules where I maintain my apache modules (mod_wsgi)
  • /swadm/var/www/django/app where I maintain my django code
  • /swadm/usr/local/python/2.6 where I'll maintain my python 2.6.7 installation with modules like django, south etc.
  • /home/swadm/setup where I'll be storing the needed source tarballs and doing all of the building and setting up from.
  • /home/swadm/workspace where I'll be maintaining application code that's in development.

The machine has python2.4.3 and python2.6.5 installed however it suggested which i maintain my very own python installation basically needed large amount of custom modules to become installed (that we could be).

And So I downloaded python2.6.7 source. I desired to make sure python is installed so that its shared library can be obtained. After I went the configure script with just the option --enable-shared and --prefix=/swadm/usr/local/python/2.6, it might get installed but remarkably indicate the system's installing of python2.6.5.

$ /swadm/usr/local/python/2.6/bin/python
Python 2.6.5 (r265:79063, Feb 28 2011, 21:55:45)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

And So I went the configure script following instructions from Building Python with --enable-shared in non-standard location as

./configure --enable-shared --prefix=/swadm/usr/local/python/2.6  LDFLAGS="-Wl,-rpath /swadm/usr/local/python/2.6/lib"

Also ensuring I'd produced the sites in advance ( because the link indicates) to prevent the errors expected. Now typing /swadm/usr/local/python/2.6/bin/python would start the right python version 5.6.7. And So I moved onto setting up and setting up mod_wsgi. I set up it as being

./configure --with-python=/swadm/usr/local/python/2.6/bin/python

the Makefile which was produced attempts to install the module into /usr/lib64/httpd/modules and that i don't have any write permissions there, and so i modified the makefile to set up into /swadm/etc/httpd/user-modules. (There can be an order argument however i couldn't decipher it). The module got produced fine. An evaluation wsgi script that we used was

import sys

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'
    output = output + str(sys.version_info)
    output = output + '\nsys.prefix = %s' % repr(sys.prefix)
    output = output + '\nsys.path = %s' % repr(sys.path)
    response_headers = [('Content-type', 'text/plain'),
                    ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]

And also the output proven was, remarkably

Hello World!(2, 6, 5, 'final', 0)
sys.prefix = '/swadm/usr/local/python/2.6'
sys.path = ['/swadm/usr/local/python/2.6/lib64/python26.zip',    '/swadm/usr/local/python/2.6/lib64/python2.6/', '/swadm/usr/local/python/2.6/lib64/python2.6/plat-linux2', '/swadm/usr/local/python/2.6/lib64/python2.6/lib-tk', '/swadm/usr/local/python/2.6/lib64/python2.6/lib-old', '/swadm/usr/local/python/2.6/lib64/python2.6/lib-dynload']`

This is why in some way the mod_wsgi module still got set up using the system's python 2.6.5 installation and never my custom one. I attempted something more important detailed within the mod_wsgi documentation

  • Set WSGIPythonHome in httpd.conf to /swadm/usr/local/python/2.6 and WSGIPythonPath to /swadm/usr/local/python/2.6/lib/python2.6
  • Produced a symlink within the python config directory to suggest towards the libpython2.6.so file

    $ ln -s ../../libpython2.6.so

After I do ldd libpython2.6.so this is exactly what I see:

$ ldd libpython2.6.so
 linux-vdso.so.1 =>  (0x00007fffc47fc000)
 libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b666ed62000)
 libdl.so.2 => /lib64/libdl.so.2 (0x00002b666ef7e000)
 libutil.so.1 => /lib64/libutil.so.1 (0x00002b666f182000)
 libm.so.6 => /lib64/libm.so.6 (0x00002b666f385000)
 libc.so.6 => /lib64/libc.so.6 (0x00002b666f609000)
 /lib64/ld-linux-x86-64.so.2 (0x00000031aba00000)

And ldd mod_wsgi.so gives

$ ldd /swadm/etc/httpd/user-modules/mod_wsgi.so
 linux-vdso.so.1 =>  (0x00007fff1ad6e000)
 libpython2.6.so.1.0 => /usr/lib64/libpython2.6.so.1.0 (0x00002af03aec7000)
 libpthread.so.0 => /lib64/libpthread.so.0 (0x00002af03b270000)
 libdl.so.2 => /lib64/libdl.so.2 (0x00002af03b48c000)
 libutil.so.1 => /lib64/libutil.so.1 (0x00002af03b690000)
 libm.so.6 => /lib64/libm.so.6 (0x00002af03b893000)
 libc.so.6 => /lib64/libc.so.6 (0x00002af03bb17000)
 /lib64/ld-linux-x86-64.so.2 (0x00000031aba00000)

I've been trying re-setting up and re-setting up python and mod_wsgi but with no success. Please tell me where I'm going wrong. (Sorry for that very lengthy publish)

TLDR System with non-root access has default python installation. I'm maintaining my very own python and python modules. mod_wsgi set up and constructed with the custom python, still indicates the system's python after i operate a test script that prints the sys version_info and path.

UPDATE: On Going through the stackoverflow (must have tried it earlier) I discovered this answer by Graham Dumpleton on mod_wsgi python2.5 ubuntu 11.04 problem which solved the mistake for me personally. Now after i do ldd mod_wsgi.so that it's from the correct shared library of python. Now i installed Django and MySQLdb using my custom python install. And Now i'm facing this error:

The following error occurred while trying to extract file(s) to the Python egg
cache:
[Errno 13] Permission denied: '/var/www/.python-eggs'
The Python egg cache directory is currently set to:
/var/www/.python-eggs
Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

And So I did change the need for PYTHON_EGG_CACHE by doing export PYTHON_EGG_CACHE=/swadm/var/www/.python-eggs. however i am still obtaining the same error. I'm looking into more. Will update after i solve this.