Apache Deployment Django Project

Source: Internet
Author: User
Tags hosting web hosting web hosting services

This article was reproduced from: http://www.cnblogs.com/fnng/p/4119712.html

I think this is a very common article, Baidu has a lot of relevant articles, incredibly still speaking with "Mod_python", I was drunk. It took some effort in some of the process. Record here.

----------------------------------------------

Until then, we've been using Django's manage.py runserver command to run the Django app, but that's just our development environment, which is not going to work when the project is actually deployed online, and we have to deploy our project to a specific Web server.

Installing Apache

Apache is a very famous Web server software, if you want to make our web project run almost without it.

Apache Official website: http://httpd.apache.org/

Depending on your environment, select the appropriate version to download. Apache website does not have a Windows 64-bit version, can be downloaded by the following link: Win7 64-bit: http://www.apachelounge.com/download/win64/

Download installation complete, Apahche directory structure is as follows:

To modify the conf/httpd.conf file:

... ServerRoot"D:/pydj/apache24"... Listen127.0.0.1:8089#Modify Port number... ServerName www.example.com:8089... DocumentRoot"D:/pydj/apache24/htdocs"<directory"D:/pydj/apache24/htdocs">... Scriptalias/cgi-bin/"d:/pydj/apache24/cgi-bin/"...<directory"D:/pydj/apache24/cgi-bin">allowoverride None Options none Require all granted</Directory>...

The main is the path and the change of port number, if you start the Apache Httpd.exe program when the Flash is gone, please check these configuration.

Start the Bin/httpd.exe program

Access via browser: http://127.0.0.1:8089/

It can now be explained that Apache work is normal.

Installing MOD_WSGI

The aim of MOD_WSGI is to implement a simple-to-use Apache module which can host any Python application which supports the Python WSGI interface.

The module would is suitable for use with hosting high performance production Web sites, as well as your average self manage d Personal sites running on

Web hosting services.

(The purpose of MOD_WSGI is to implement a simple use of the Apache module that can host any Python application that supports Python's Wsgi interface.) The module will be applied to host the high-performance production site, as well as the general self-management of the web hosting service of the personal site run. The direct Google Translator, a rough understanding of what to do.

MOD_WSGI Website: http://code.google.com/p/modwsgi/

: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi

For example, Win7 64-bit, Python 2.7.6, Apache (httpd-2.4.10) corresponds to the version: Mod_wsgi-3.5.ap24.win-amd64-py2.7.zip

After extracting, you will get a mod_wsgi.so file and copy it to the Apache24\modules\ directory.

Configuring Apache and Django Projects

Because your directory must be the same as mine, so I would like to highlight my directory:

Apache Storage directory: D:\pydj\Apache24

Django Project directory: D:\pydj\myweb

Hit Apache again with the compounding file httpd.conf:

... #添加mod_wsgi. So module loadmodule wsgi_module modules/mod_wsgi.so# Specify the wsgi.py profile path for the MyWeb project wsgiscriptalias/d:/pydj/ Myweb/myweb/wsgi.py# specifying the project path Wsgipythonpath d:/pydj/myweb<d:/pydj/myweb/myweb > <  wsgi.py>    Require all granted</Files  ></Directory>

The above path, please modify according to your actual situation.

Configure the myweb/wsgi.py file below:

Import Osos.environ.setdefault ("django_settings_module""  Myweb.settings")fromimport= get_wsgi_application ()

This information is generated automatically when we build the Djnago project, but we don't have to make any changes to it.

Open a settings.py file to add:

= ['127.0.0.1'localhost']

Start the Apache24/bin/httpd.exe program again

Access via browser: http://127.0.0.1:8089/

PS: Here are a few of the big pits I've met!

1.WIN7 64-bit machine, Apache must use 64-bit!!!!!!

2. The new version of the Mod_wsgi download down is the *.WHL format of the file, to use PIP installation, but also to 64-bit. Note here that after the download installation is complete, there is no mod_wsgi.so!!

Here you need to find the mod_wsgi.pyd file in the Python folder, which can replace the mod_wsgi.so file.

Put *.pyd files into Apache Modules folder, and then in the configuration of the corresponding mod_wsgi.so replaced with MOD_WSGI.PYD, start Apache no problem!

Apache Deployment Django Project

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.