How to setup Apache and mod_python and django

来源:互联网 发布:mac如何退出qq 编辑:程序博客网 时间:2024/05/18 02:05

Here is the tutorial:

 

 

1. Install Apache2.2

Please refer to other article!

 

2. Install mod_python

Please go to mod_python site to download the compatible version, then install it.

After the installation, a module named "mod_python.so" will be added to modules folder in Apache root.

 

3. Install python2.5

Please go to python site to download the python, then install it.

 

4. Install django-1.1.1

Please go to django site to download the django-1.1.1, then move to Python's site-packages folder.

 

5. Create the website

I just add a workspace under the D:, and start a project named "mycompany".

The folder structure seems like:

D:/djworkspace/mycompany

 

6. Edit httpd.conf of Apache to run the django.

a) Enable the mod_python, just add below segment:

 

##########################################################################

# Load Python Module

LoadModule python_module modules/mod_python.so

##########################################################################

 

b) Setup website

<VirtualHost *:84>

DocumentRoot "D:/djworkspace/mycompany/"

 

# Serve django pages

<LocationMatch ^/(.*)$>

SetHandler mod_python

PythonHandler django.core.handlers.modpython

SetEnv DJANGO_SETTINGS_MODULE mycompany.settings

PythonOption django.root

PythonAutoReload Off

PythonDebug On

PythonPath "sys.path + ['D://djworkspace', 'D://djworkspace//mycompany']"

</LocationMatch>

 

# Serve static media without running it through mod_python (overrides the above)

<LocationMatch ^(/(media|css|images|scripts|errordocs))>

SetHandler None

</LocationMatch>  

 

<Directory "D:/djworkspace/mycompany/"> 

Order allow,deny

Options Indexes

Allow from all

</Directory>

 

</VirtualHost>

 

7. Run the site

 

原创粉丝点击