Windows compilation installs Mod_wsgi, with DJANGO+APAHCE

Source: Internet
Author: User
Tags vc9 install django pip install django

Compilation Environment:

Are 32-bit versions

Microsoft Visual Studio 10.0

Microsoft SDKs v7.1

Apache2.4

Python3.4

mod_wsgi-4.5.0

Requirements:

1 Apache and Python are both 32-bit or 64-bit,

2 Apache and Python are compiled by the same version of the C + + compiler

3 compile Mod_wsgi using the same version of the C + + compiler as above

Must be met at the same time to succeed

Description: vc9==vs2008 or vc10==vs2010

Python 2.6 or 2.7--VC9

Python 3.3 or 3.4--VC10

    

Compilation process

Unzip the Mod_wsgi-4.5.0.zip, enter the Win32 directory, like the Mk file below

ap22py26-win32-vc9.mkap22py27-win32-vc9.mkap22py32-win32-vc9.mkap24py26-win32-  Vc9.mkap24py26-win64-vc9.mkap24py27-win32-vc9.mkap24py27-win64-vc9.mkap24py32- win32-vc9.mkap24py32-win64-vc9.mkap24py33-win32-vc10.mkap24py33-win64-  Vc10.mkap24py34-win32-vc10.mkap24py34-win64-vc10.mk

What we need here is ap24py34-win32-vc10.mk , modify the content inside.

Apache_rootdir = D:\IT\Apache24       =include common-vc10.mk

Set temporary environment variables in cmd

SetPath=C:\Program Files\Microsoft Sdks\windows\v7. 1\ bin;C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\bin;C:\Program Files (x86) \microsoft Visual Studio 10.0  \common7\ide;SetInclude=C:\Program Files\Microsoft Sdks\windows\v7. 1\include;C:\Program Files (x86) \microsoft Visual Studio 10.0  \vc\include;Setlib=C:\Program Files\Microsoft Sdks\windows\v7. 1\lib;C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\lib;

#注意path和 = There can be no space between, and the last IDE of path is less, otherwise it will not find the Mspdb100.dll in its directory

Now it is possible to compile in cmd

Cd/path/to/win32

Nmake-f ap24py34-win32-vc10.mk Install

Waiting for the compilation to finish, will generate mod_wsgi.so in the Win32 directory, while the Apache modules directory generated mod_wsgi-py34-vc10.so, two files the same.

Installing Django

Pip install django==1.9              has already installed an older version or can be upgraded to the latest version: Pip Install--upgrade Django

Test using:

In the D:\WebRoot\DjangoProject directory, the cmd command runs:

Django-admin  startproject  mysite     creation Project

CD MySite

Python3 manage.py runserver running the server

Browser 127.0.0.1:8000 appears it worked! instructions OK

Modify mysite/wsgi.py This file is Apache find the Django Project interface

#! C:\Python34\python.exe     #否则会报错: wsgi.py is not executable; ensure interpreted scripts has "#!" or "'!" first line C4>import  osimport  sys      #添加这三行 to resolve Importerror:no module named ' MySite ' ERROR   /path/to/mysite.com No use, still don't know why ... 
= Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__


from Import

Os.environ.setdefault ("django_settings_module""mysite.settings "

= Get_wsgi_application ()

Configure wsgi.py

 LoadModule wsgi_module modules/mod_wsgi-py34-vc10.so #加载模块 wsgiscriptalias 
    / d:/webroot/djangoproject/mysite/ mysite/wsgi.py    #/Represents the root path (base URL), That is, when you enter HTTP://127.0.0.1/, you will find wsgi.py to enter the Django project  <directory  " d:/webroot/djangoproject/mysite/mysite   > Set permissions for the directory where wsgi.py is located  SetHandler wsgi -
//path/to/mysite.com/mysite//path/to/mysite.com        <directory/path/to/mysite.com/mysite ><files wsgi.py>Require all granted</Files></Directory>

Launch Apache Service

Browser 127.0.0.1 shows Django's IT worked! instructions Apache successfully loaded the Django project!

Windows compilation installs Mod_wsgi, with DJANGO+APAHCE

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.