Django deployment to Apache server

Source: Internet
Author: User

The Django project itself can start running, why do you need to deploy to Apache or Nginx? Beginners will encounter this problem, let's take a look at the official explanation: It's intended only with use while developing. (We ' re in the business's making web frameworks, not Web servers.), which means that Django is making a web framework, not a Web server. The self-brought Web server is just easy to develop, and can not directly put into production environment, interested students can test their performance gap. To get to the point, we're here to explain how to build Apache environments.

Installing Apache

Apache (Win 64) Download: https://www.apachehaus.com/cgi-bin/download.plx#APACHE24VC09

1. Unzip to the E-drive and modify the E:\Apache24\conf\httpd.conf file.

...... "E   :/apache24 "     "${srvroot}" ... 12.34. 56.78:8088 ... ServerName localhost:8088 ...

2. Open E:\Apache24\bin\httpd.exe, in the browser input http://127.0.0.1:8088/appears welcome page represents success.

Mod_wsgi

Mod_wsgi module Download: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi 1. Change the WHL file to zip, unzip, Copy the inside mod_wsgi.so to the E:\Apache24\modules path., a new configuration is added to the httpd.conf:
# Add mod_wsgi.so module   LoadModule Wsgi_module modules/mod_wsgi.so  

2. If the mod_wsgi.so file cannot be found after Mod_wsgi decompression (if you skip this step)

Run cmd and go to the scripts directory to perform the installation operation:

PIP3 Install MOD_WSGI-4.5.17+AP24VC10-CP34-CP34M-WIN_AMD64.WHL

In the Scripts directory execution: mod_wsgi-express module-config

Copy the three lines of content to the new additions in step 1 of the httpd.conf replacement:

# Add mod_wsgi.so module   " C:/python34/dlls/python3.dll "  "c:/python34/lib/site-packages/mod_wsgi/server/mod_wsgi.pyd "  " C:/python34 "

Configuring Apache and Django

1. Open the Apache config file httpd.conf and add a configuration at the end:

#Add mod_wsgi.so moduleLoadFile"C:/python34/dlls/python3.dll"LoadModule Wsgi_module"C:/python34/lib/site-packages/mod_wsgi/server/mod_wsgi.pyd"Wsgipythonhome"C:/python34"  #Specify the wsgi.py configuration file path for the MyWeb projectwsgiscriptalias/d:/mysite/mysite/wsgi.py#Specify Project PathWsgipythonpath d:/MySite<directory d:/mysite/mysite> <files wsgi.py>Require All granted</Files> </Directory>Alias/static d:/mysite/Static<directory d:/mysite/static>allowoverride None Options none Require all granted</Directory>

2. Open the Django Project setting configuration:
DEBUG == ['127.0.0.1','localhost']  # the IP that is allowed to access. Can also be expressed as ' * ', which means unrestricted

Finally, restart Bin\httpd.exe, enter the URL

Welcome reprint, Reproduced please indicate the source: Tmself's Blog: http://www.cnblogs.com/shenh/p/7552722.html





Django deployment to Apache server

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.