IIS7 Deployment Django Site Guide

Source: Internet
Author: User

Operating Environment:

Windows Server 2008 R2 Enterprise (64-bit)

IIS 7.5

IIS 6.0 Compatibility Management

SQL Server 2005


Note: IIS 6.0 Compatibility management must be installed


Required Software:

Please go to the official website to download, all the installation packages are 32-bit.

Window Installer is the installation package for the EXE, and django,django-pyodbc,isapi_wsgi please download the Python installation package

The Python installation package is actually Python's source code, usually containing a setup.py installation file, entered at the command line: Python setup.py install.

Note that because Window Server 2008 is more stringent on security management, it is recommended that you run as an administrator when you install the command line, as follows:

Enter CMD in the search box


Press Ctrl+shift+enter at the same time, the Prompt box appears select "Yes"



Installation steps:

1. Install Python27

2. Install Setup-tools, Pywin32, Pyodbc, Django, Django-pyodbc, Isapi_wsgi. (Easy to install, it's not going to be a game of Python)

3. Modify the manifest of the Pyodbc.pyd file with the Mt.exe tool. (Please refer to my other article http://blog.csdn.net/omage/article/details/7320918)

(Mt.exe is a tool for generating symbol files and catalog listings, in Windows Software Development Kit (SDK), if you have visual Studio installed, usually in

Program Files\Microsoft Sdks\windows\v6.0a\bin Directory. This step is due to the pyodbc of a small bug. )

The method is as follows:

(1) Run the command line as an administrator and enter the directory where Mt.exe resides

(2) Enter the command:

Mt.exe-inputresource:c:\windows\syswow64\python27.dll; #2-outputresource:d:\python27\lib\site-packages\ Pyodbc.pyd; #2

4. Add a Web site on the IIS7 manager


5. Confirm that the 32-bit application is enabled to be true



6. Use a script to deploy your Django site (refer to another blog post http://blog.csdn.net/omage/article/details/7291403)

Create a deployment script wsgi_deploy.py that reads as follows

Import OS, sys

Sys.path.append (' D:\\webdjango ')

Sys.path.append (' D:\\webdjango\\mysite ')



os.environ[' django_settings_module '] = ' SETTINGS '



Import Django.core.handlers.wsgi

application = Django.core.handlers.wsgi.WSGIHandler ()



Import Isapi_wsgi

# The entry points for the ISAPI extension.

Def __extensionfactory__ ():

Return ISAPI_WSGI. Isapisimplehandler (Application)



If __name__== ' __main__ ':

# If run from the command-line, install ourselves.

From Isapi.install Import *

params = Isapiparameters ()

# Setup The virtual directories-this is a list of directories our

# extension Uses-in this case only 1.

# Each extension has a ' script map '-This is the mapping of ISAPI

# extensions.

SM = [

Scriptmapparams (extension= "*", flags=0)

]

VD = Virtualdirparameters (name= "MySite"),

Description = "Isapi-wsgi isapisimplehandler Django MySite",

scriptmaps = SM,

Scriptmapupdate = "Replace"

)

Params. Virtualdirs = [VD]

Handlecommandline (params)


Run the command Line window with the administrator and enter it in the script directory: Python wsgi_deploy.py install--server Webdjango

(Note that Webdjango is the Web site that you just created), and when the script runs successfully, the MySite app and the wildcard script map are created in IIS.




7. Open the browser, try to see if your site can be opened, WOW, successful yes.







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.