Apache+mod_python+django Configuration under Windows

Source: Internet
Author: User

Apache+mod_python+django configuration under Windows



Apache

First to install Apache, I installed the version is 2.2.*;

Python

Python must be installed, I installed the version is 2.5, the high version has not mod_python support, it needs to use MOD_WSGI to support, that I match, although successful, but did not go into detail wsgi this east, but this is certainly a trend, mod_ Python is a eunuch product. Off the topic. Python installation directory: D:\Python25, after the installation is complete, add D:\Python25 to the path of the system environment variable.

Mod_python
Installation of Mod_python-3.3.1.win32-py2.5-apache2.2.exe is required for Apache2.2, and if Apache is a 2.0.* version it will need to be installed Mod_ Python-3.3.0b.win32-py2.5-apache2.0.exe, otherwise you will not find mod_python.so errors in restarting the Apache times, and you see modules below Mod_ Python.so is inside, this indicates that the version is not installed.

Mod_python installation is relatively simple, in the middle to choose your Apache installation directory.

Django
To support Django, you're going to download Django. The version I downloaded is Django-1.3.1.

Django installation, after decompression, msdos into its directory, run the command "Python setup.py install" will be able to put Django installed successfully, after successful will be in D:\Python25\Lib\ See the Django folder under the Site-packages directory. After installation, add D:\python25\Lib\site-packages\django\bin to the path of the system environment variable.

Project builds

Preferably in your own working directory, my working directory is: E:/applications/forpython, enter MSDOS, Run command "django-admin.py startproject pyweb", where Pyweb is the name of my project, After success, you will see the Pyweb directory under Forpython.

Apache Configuration
The front is simple things, the following configuration is the core of this article, open the Apache configuration file httpd.conf, find a large heap of loadmodule, in front of the following statements are added:
LoadModule Python_module modules/mod_python.so
In Httpd.conf last added
<virtualhost 127.0.0.1:80>
DocumentRoot "E:/applications/forpython"
<directory "E:/applications/forpython" >
AllowOverride None
Options Indexes FollowSymLinks
Order Allow,deny
Allow from all
</Directory>
<location "/pyweb" >
SetHandler Python-program
#AddHandler Python-program. py
PythonPath "[' D:/python25/lib/site-packages/django/bin ', ' D:/python25/lib/site-packages/django ', ' E:/Applications /forpython ', ' e:/applications/forpython/pyweb ']+sys.path '
Pythonhandler Django.core.handlers.modpython
SETENV Django_settings_module pyweb.settings
Pythoninterpreter inves
Pythondebug on
</Location>
</VirtualHost>
Note: The definition behind Pythonpath, try to include the Django path and the path of your project, otherwise it will prompt the path error, and the error occurs.

At this point, the entire configuration is complete, restart Apache,ie access: Http://localhost/pyweb, see, Description succeeded. If your configuration is not successful, please pay more attention to Apache's error.log and find out why.

If still can't solve the problem, the big deal will all the demolition redo.

Apache+mod_python+django Configuration under Windows

Related Article

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.