Configure the django runtime environment in windows + apache + mod_python

Source: Internet
Author: User

1. Create mysite test site: django-admin.py startproject mysite

2. Create a test page: hello. py. The content is as follows:

From django. http import HttpResponse

Def index (request ):
Return HttpResponse ('hello, Django! ')

3. Create the mod_py_dj.conf configuration file. The content is as follows:

LoadModule python_module modules/mod_python_so.pyd

Listen 8081.
Namevirtualhost*: 8081
<VirtualHost *: 8081>
<Location "/">
SetHandler python-program
PythonPath "['d: \ open \ www '] + sys. path"
PythonHandler django. core. handlers. modpython
SetEnv DJANGO_SETTINGS_MODULE mysite. settings
PythonAutoReload Off
PythonDebug On
</Location>
</VirtualHost>

Note: In this VirtualHost, you do not need to configure DocumentRoot; otherwise, add the following:

<Directory "d: \ open \ www">
Options FollowSymLinks
AllowOverride All
Order allow, deny
Allow from all
</Directory>

Do not configure DocumentRoot. Reduce the configuration.

4. Modify the url. py file and add a line:

(R' ^ hello/$ ', 'mysite. hello. Index ')

5. Test: http: // localhost: 8081/hello/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.