Configure Python Django in Windows 7 Apache

Source: Internet
Author: User

1. Download httpd-2.2.16-win32-x86-no_ssl.msi Installation

NOTE: If IIS is enabled, stop it.

 

2. Download mod_wsgi-win32-ap22py26-3.3.so

: Http://code.google.com/p/modwsgi/downloads/detail? Name = mod_wsgi-win32-ap22py26-3.3.so

 

3. Modify the mod_wsgi-win32-ap22py26-3.3.so to mod_wsgi.so and copy it to C:/program files/Apache Software Foundation/apache2.2/modules (the specific directory is the directory where you install Apache)

 

4. Modify httpd. conf (generally in C:/program files/Apache Software Foundation/apache2.2/conf) and add the following content:

 

Loadmodule wsgi_module modules/mod_wsgi.so

Wsgiscriptalias/"D:/Django/bin/blogmysite/Django. wsgi"

<Directory "D:/Django/bin/blogmysite">

Options followsymlinks

AllowOverride none

Order deny, allow

Allow from all

</Directory>

 

 

Note: Install Django in D:/Django.

The new proejct is called blogmysite.

The newly created app is called blog.

 

5. Create a wsgi file in the project directory (my file is D:/Django/bin/blogmysite/). The content is as follows:

Import OS

Import sys

Import Django. Core. Handlers. wsgi

 

 

SYS. Path. append ('d:/Django/bin ')

SYS. Path. append ('d:/Django/bin/blogmysite ')

SYS. Path. append ('d:/Django/bin/blogmysite/blog ')

OS. Environ ['django _ settings_module '] = 'blogmysite. setting'

 

Application = Django. Core. Handlers. wsgi. wsgihandler ()

 

 

6. Browse and enter http: // localhost/blog to display normally

 

If an error occurs, view C:/program files/Apache Software Foundation/apache2.2/logs/error. log.

If the following error occurs:

Importerror: No module named XXX. Models

Or

[Tue Aug 17 23:11:22 2010] [Error] [client 127.0.0.1] importerror: cocould not import settings 'xxx. setting' (is it on SYS. Path? Does it have syntax errors ?) : No module named XXX. Settings

You can add relatedProgramDirectory (SYS. Path. append ('your directory'), be sure not to end)

 

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.