Install Python2.5 and mod_python to CentOS(64bit)


64ビット版CentOSに、Pythonmod_pythonをインストールする件についてです。Linuxコンポーネント管理ツールyum がシステムのPythonバージョンに依存するので、システムPythonをアップグレードすることができません。なので、独自のPythonをインストールします。


CentOS system global Python version is 2.3. This is not able to upgrade!! OS component manager of "yum" depends on Python2.3. If Python might be upgraded, yum will dead and all components (contains Python) will never be managed. We need alternative install to another directory for modern Python and its modules.


To avoid static link by python modules(e.g. mod_python) you should run configure script with "--enable-shared" option.

If ".so" might not be found on running Python, add the shared library dir to "" settings and run ldconfig.

$ ./configure --enable-shared

(install dir is not considerd because the configure's default prefix is /usr/local.)

To enable SSL, installing openssl-devel required. It's convenient to test your secure application with urllib or urllib2 module by itself.

$ yum install openssl-devel

Edit openssl installed prefix(/usr) and libraly directory(lib64) in Modules/Setup in Python source code.

_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib64 -lssl -lcrypto

Build and install.

$ make
$ make install

Enable to find your dyamic link liblary.

$ echo /usr/local/lib > /etc/
$ ldconfig


"apxs" is extension development framework for Apache web server. mod_python requires apxs.

$ yum install httpd-devel


IMPORTANT: Don't forget to specify your own compiled Python with --with-python.

$ ./configure --with-python=/usr/local/bin/python2.5
$ make
$ make install

Add mod_python to Apache config and restart web server.

$ echo LoadModule python_module /usr/lib64/httpd/modules/\
  > /etc/httpd/conf.d/python.conf

$ service httpd restart