Introduction to Python development and practical 16-apache deployment

Source: Internet
Author: User

Windows platform Apache Deployment

In this section, we briefly describe how toWindowsPlatform deploymentApacheOfDjango site.

Python Django Project Deployment is published to the Windows Apache Runtime Environment:

operating system : Windows 8.1 x64

python version : 2.7 x86

Django version : 1.4

Apache version : 2.2.4 x86

16.1. Installing the Apache Environment

APPACHE:HTTP://WWW.APACHEHAUS.COM/CGI-BIN/DOWNLOAD.PLX Download the 32-bit Apache file.

Note: since Mod_wsgi.iso does not support the 64-bit version, we all use the 32-bit version here, including Python version 2.7.

16.2. Configuring the Appache Django Mod_python Environment

Unzip the folder Apache24 to the C:\Program Files folder, run the command prompt as administrator, and go to the C:\Program files\apache24\bin directory. Run the following command to register the APACHE24 service to the server.

Httpd.exe-k Install

16.3. Download the mod_wsgi.so file

Http://code.google.com/p/modwsgi/downloads/list Download the required version, in this case the Mod_wsgi?3.5.ap22.win32?py2.7.zip version is extracted mod_ wsgi.so file.

Copy the mod_wsgi.so file to the Modules folder in the Apache installation directory.

16.4. Configure Appache

1) in the Apache installation profile directory conf\httpd.conf, add a line:

    LoadModule Wsgi_module modules/mod_wsgi.so

2) Add another line as follows:

    Wsgiscriptalias/"C:\My Files\python projects\mysite\mysite\mysite\wsgi.py"

The configuration above configures the Apache interpretation execution Portal file to be a Python Django project wsgi.py file

3) Project wsgi.py Add system path

Import  os,syssys.path.append (Os.path.dirname (os.path.dirname(__file__))) Os.environ.setdefault ("django_settings_module""mysite.settings ")

4) Locate the configuration area of the Apache http.conf file directory and add the following configuration

" C:\Program Files\apache24\mysite\mysite ">    Options none      allowoverride none      Require all granted</Directory>

5) Restart Aapche.

16.5. static file Configuration

We are not yet able to access the page Inventoryqueryextjs that requires static file support, and then we complete the configuration of the Apache static file directory. Ditto our static file collection command to collect static files into the project directory static folder, in the configuration area of the http.conf file directory, add a static file configuration.

 <directory  c:\program Files\apache24 \mysite\mysite   > Options None Allowo Verride None Require All granted  </directory>alias   /static  " Span style= "color: #800000;" >c:\program files\apache24\mysite\static/  <directory  " c:\program files\apache24\mysite\static/      ;   </directory>  

The re-access http://127.0.0.1/inventoryQueryExtjs/page is displayed properly, and we have completed the deployment of the Windows platform Apache service

16.6. Summary

In this section we briefly explain how to publish our website on the Windows Apache platform, so far our publishing model is local server mode, and the next section describes how to publish our services on the cloud.

Introduction to Python development and practical 16-apache deployment

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.