Apache Deployment Django Project

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

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. In some records.

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

Until then, we've been using Django 's manage.py runserver command to run Django application, but this is just our development environment, when the project is actually deployed on-line, this is not going to work, we must 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 official Website No Windows -bit version, which can be downloaded via the link below: Win7 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" ... Listen 127.0.0.1:8089 #修改端口号 ... 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 Apache module that can host any python application that supports python of the 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

such as win7 ,python 2.7.6,Apache(httpd-2.4.10 The corresponding version is: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:

... # Add mod_wsgi.so module LoadModule wsgi_module modules/mod_wsgi.so
# Specifies the wsgi.py configuration file path for the MyWeb project wsgiscriptalias/d:/pydj/myweb/myweb/wsgi.py
# Specify Project path wsgipythonpath d:/pydj/myweb<directory d:/pydj/myweb/myweb><files 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/

=================================

Note: Recent blog no more technology, because I am in the collation of the Django Learning Manual, is a must let you learn to develop a website manual, no nonsense, no sermon, then do, the original with Django developed as simple.

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.