Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Web Server Setup for Linux

Introduction

We are unsing centos.

  1. uname -a
    Linux sfmaps_web 2.6.18.8-xenU #1 SMP Mon Aug 18 14:00:41 PDT 2008 x86_64 x86_64 x86_64 GNU/Linux

The following must be installed for everything to work properly.

  • python 2,5,4
  • mod_wsgi 2.5
  • psycopg2 2.0.12
  • django
  • geos
  • proj4
  • gdal
  • dos2unix

The following will assist you to reconstruct this environment on linux.
Your actual mileage may vary.

It is important that at every step you specify the right versions.
Since you may have 2 version of python, its very easy to get a python component wrong.
Not that this ever happened to me.
For example, when installing mod_wsgi, if you do not explicitly specify the
right version, the default version will be used. This may cause problems
that are difficult to trouble shoot.

 

System Administration Essentials

You will need a moderate amount of unix foo (fu) to do this.
If you are a real unix sys-admin, skip this section.

At many points through out this installation, you may see something to this effect:

Libraries have been installed in:
/usr/lib64/httpd/modules
(...and some additional text)

When you do, you must add the directory to the dynamic linker run-time bindings.

  1. echo '/usr/lib64/httpd/modules' >> /etc/ld.so.conf.d/local-lib.conf
  2. ldconfig

Generally, building software from source follows the following pattern.
Create and cd to a consistent location where you do your builds.

  1. mkdir ~/builds
  2. cd ~/builds
    Download and unpackage the source.
  3. wget http://initd.org/pub/software/psycopg/psycopg2-2.0.12.tar.gz
  4. tar xvfz psycopg2-2.0.12.tar.gz
    Change to the directory that contains the source.
  5. cd psycopg2-2.0.12
    And build the software:
  6. ./configure
  7. ./make
    Install the software.
    You must have elevated privileges to install.
  8. sudo make install

In real life, there are usually variations to the above pattern,
sometimes significant variations.

Preliminaries

Install development packages for apache httpd

  1. sudo yum install apr-devel.x86_64
  2. sudo yum install httpd-dev.x86_64
  3. sudo yum install glibc-common
  4. sudo yum install zlib-devel.x86_64
PYTHON2.5

http://www.python.org/ftp/python/2.5.4/Python-2.5.4.tgz

Compile and install 2.5.4 along side what ever python version is already installed.
Using "altinstall" allows mutliple versions to be installed.
When using "altinstall" note that you must type "python2.5" and not "python" to get
the right version. Enable 4 byte unicode so it plays nice with psycopg2.

Build

  1. ./configure --enable-unicode=ucs4
  2. make
  3. sudo make altinstall

Test

  1. python2.5
    Python 2.5.4 (r254:67916, Aug 25 2009, 10:11:25)
    GCC 4.1.2 20080704 (Red Hat 4.1.2-44) on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

Links http://effbot.org/pyfaq/when-importing-module-x-why-do-i-get-undefined-symbol-pyunicodeucs2.htm http://www.fishandcross.com/blog/?p=610

MOD_WSGI 

http://modwsgi.googlecode.com/files/mod_wsgi-2.5.tar.gz

This is the software that allows python to run on httpd.
It is supposed to a fast, solid, production python "application server".
Make sure you install the apache httpd dev libs first.
Be very sure that you tell configure to use the right version of python...
not that this caused me any trouble.

  1. ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/local/bin/python2.5
  2. make
  3. sudo make install

Configure Apache to use mod_wsgi
First we need to check if apache is loading mod_python, search the httpd configs in /etc/httpd/
recursively for the string "python_module". If this module is loaded, commented it out.
In the main httpd config file: /etc/httpd/httpd.conf, include the eas config file mad.htconf.

#vi /etc/httpd/conf/httpd.conf

scroll down to the bottom and enter the line:
Include /var/www/html/eas/mad.htconf

Links http://code.google.com/p/modwsgi/

PSYCOPG2

http://initd.org/psycopg/tarballs/PSYCOPG-2-0/psycopg2-2.0.12.tar.gz

This is the python database driver for postgresql.

First you must install some postgres development packages.

  1. sudo yum install postgresql-devel.x86_64
    Note the location of the pg configuration program...
  2. find / -name pg_config

Inside the psycopg2 package, you'll need to find and edit setup.cfg
so that its knows the location of pg_config.

Run the install.

  1. sudo python2.5 setup.py install
    Take great care here to use the right version of python.
    Note that this was ever an issue for me.

links http://initd.org/

GEOS

http://download.osgeo.org/geos/geos-3.1.1.tar.bz2

preliminary

  1. yum install gcc-c++
  2. sudo yum install python-devel (to support python bindings)
  3. sudo yum install swig (to support python bindings)

install

  1. ./configure (or ./configure --enable-python)
  2. ./make (or just make)
  3. sudo ./make install

links http://geodjango.org/docs/install.html

PROJ.4

A bit unusual; follow these instructions:
http://geodjango.org/docs/install.html#proj4

links http://geodjango.org/docs/install.html

 

GDAL

http://download.osgeo.org/gdal/gdal-1.6.2.tar.gz
http://geodjango.org/docs/install.html

Without GDAL, geodjango wfs does not work.
We build without the gdal python bindings because geodjango has its own.
The install is bog standard; make takes a good while.

  1. ./configure ./configure --with-python
  2. make
  3. sudo make install
DJANGO

Since this is pure python, you can copy this into the python site-packages.
Or install as you see fit.

  1. sudo python2.5 setup.py install

 

JOGGING

Download Jogging v0.2.2 http://github.com/zain/jogging/zipball/v0.2.2
or
Http://github.com/zain/jogging/tarball/v0.2.2
in Windows: unzip file, copy the content folder called "jogging" to C:\Python25\Lib\site-packages or /usr/local/lib/python2.5/site-packages
in Linux: get gz file, unzip, untar, then run from jogging directory: $ python2.5 setup.py install

For the Change Notification process, the xmit_daemon.py script uses a system variable called MAD_HOME.
MAD_HOME is set by xmit_change_notifications.bsh; it must point to the path where the web application is deployed.
MAD_HOME is used to access the django settings.py.
This daemon process runs outside of the web server.

ADMIN

You want to make sure the web server starts on reboot.
To accomplish this:

$ chkconfig httpd on

...is it really just that simple?

  • No labels