How to setup Apache and mod_python and django

本文档提供了一套详细的步骤来安装并配置Apache、mod_python、Python及Django,以便搭建和运行一个基本的Django网站。包括安装所需软件、设置Apache以支持Django应用程序、配置虚拟主机等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值