(Disclaimer: I just started using Linux and don't have much experience with configuring Apache and Python.)
I have a rather common issue that is explained in more depth here http://code.google.com/p/modwsgi/wiki/IssuesWithExpatLibrary. Basically, I'm 99% sure that my main issue is that my Apache is using version 1.95.7 of the expat library, whereas my Python is using version 2.0.1 of the expat library; thus, when I use them together I get a segmentation fault.
As is explained in the link at the very bottom of the page, I need to replace/update the version of the expat library that is used by Apache to the version used by Python. How would I do this? (Keep in mind I'm very inexperienced with this sort of thing.)
EDIT: This issue has been resolved. Below I documented everything I did to install Apache, build Python from source code, install mod_wsgi, and resolve the dreaded expat issue for my reference and for that of anyone else who experiences a similar issue.
1) Installed Ubuntu with Wubi
Installing Apache
2) On Ubuntu, downloaded Apache Unix Source httpd-2.2.21.tar.gz
3) Extracted the source from the Apache HTTPDd tarbell:
gzip -d httpd-2.2.21.tar.gz
tar xvf httpd-2.2.21.tar
4) Configured the Apache HTTPd source tree from within extracted directory:
sudo ./configure --prefix=/usr/local/apache2
5) Built the various parts which form the Apache HTTPd package:
sudo make
6) Installed the package under the directory I specified in step 4
sudo make install
7) Started Apache HTTP Server:
sudo /usr/local/apache2/bin/apachectl -k start
8) Checked localhost and it printed "It works!"
9) Stopped Apache HTTP Server:
sudo /usr/local/apache2/bin/apachectl -k stop
Installing Python from source code
10) Fetched all the common packages needed to build anything (e.g. the compiler etc.)
sudo apt-get install build-essential
11) Edited sources.list file in /etc/apt by adding the exact same "deb" lines contained in the file to the end except with "deb-src":
sudo nano /etc/apt/sources.list
12) Updated apt-get to recognize the change:
sudo apt-get update
13) Fetched all the libraries needed to build Python:
sudo apt-get build-dep python2.7
14) Downloaded python source code Python-2.7.2.tgz, extracted it, and ran the following from within the directory:
sudo ./configure --enable-shared --prefix=/usr/local
15) Built Python:
sudo make
16) Installed Python:
sudo make install
Installing mod_wsgi
17) Downloaded mod_wsgi source code tar ball mod_wsgi-3.3.tar.gz
18) Unpacked and configured with python from within unpacked directory:
sudo ./configure --with-apxs=/usr/local/apache2/bin/apxs \
--with-python=/usr/local/bin/python2.7
19) Built the configured package:
sudo make
20) Installed in Apache modules:
sudo make install
21) Downloaded Django-1.3.1.tar.gz
22) Extracted file:
tar xzvf Django-1.3.1.tar.gz
23) Installed Django project from within directory:
sudo python setup.py install
24) Edited Apache httpd.conf file:
sudo nano /usr/local/apache2/conf/httpd.conf
Added the following directive to the end of the file:
LoadModule wsgi_module /usr/local/apache2/modules/mod_wsgi.so
WSGIScriptAlias / /usr/local/lib/python2.7/site-packages/django/test.wsgi
<Directory /usr/local/lib/python2.7/site-packages/django>
Order deny,allow
Allow from all
</Directory>
25) Created a test file in django project directory:
sudo nano /usr/local/lib/python2.7/site-packages/django/test.wsgi
Added the following content to the file:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
26) Started Apache:
sudo /usr/local/apache2/bin/apachectl -k start
27) Tested localhost and it printed "Hello World!"
28) Stopped Apache:
sudo /usr/local/apache2/bin/apachectl -k stop
Testing the Dreaded Expat Issue:
29) Edited test.wsgi file:
sudo nano /usr/local/lib/python2.7/site-packages/django/test.wsgi
Added the following content to the top of the file:
import pyexpat
30) Started Apache:
sudo /usr/local/apache2/bin/apachectl -k start
31) It prints "Hello World!" There is a God.
32) Stopped Apache:
$ sudo /usr/local/apache2/bin/apachectl -k stop