ubuntu1404+django1.9+apache2.4 Deployment Configuration 2 configuration File Settings

Source: Internet
Author: User
Tags apache error log

Reprint annotated source, personal blog: Http://www.cnblogs.com/wdfwolf3/Django The primary deployment platform is WSGI, which is the standard for Python Web servers and applications. Using Apache and Mod_wsgi to deploy Django is a way to put Django into a productive environment,Mod_wsgi is an Apache module that can host any Python WSGI application. Other well-known modules such as Mod_python and Fastcgi,mod_python are completely removed in Django1.5 and fastcgi are not supported and deleted in Django1.9. Let's start with the configuration.

1.

From Path/etc/apache2/, open the file apache2.conf and add the following code. The first path of the first line is the underlying URL path, and the second path is the full path to your project's wsgi.py file, which tells Apache to use this Wsgi app to respond to any request under this URL. The second behavior of the project path ensures that your project can be imported correctly, and the third behavior wsgi.py the path to the folder where the directory section is used to enable Apache to navigate to the wsgi.py file. If the Apache version is less than 2.4, replace the require all granted with the Allow from all and add the order Deny,allow line above it.

Wsgiscriptalias/"/home/wdf/mysite/mysite/wsgi.py" wsgipythonpath/home/wdf/mysite<directory/home/wdf/mysite/ Mysite><files Wsgi.py>require All granted</files></directory>

2.

If you change from a debug environment to a production environment, you also need to turn debug from true to False. You can't use 127.0.0.1 to open a Web page like you did before, you need to change the project's settings file, open the settings.py file in the Django project, add the following line of code,

allowed_hosts = ['127.0.0.1']

Adding a ' localhost ' to the list can also be used for debugging.

3.

If you start Apache (Command sudo service apache2 start) error,

 not reliably determine the server'
' ServerName' directive globally to suppress this message

Then add the following line of code to the config file apache2.conf.

ServerName localhost

Default port 80, can not write.

4.Apache error Log Error.log

When I open the Web page still can't access to my Django project, Apache normal boot no problem, then need to open the error log file/var/log/apache2/error.log (if the path is different through http://www.cnblogs.com/ Wdfwolf3/p/5438379.html method), found the following error,


' \\xe5 ' inch
for details

This is more common, coding problems, we go back to the wsgi.py file, the beginning of the file to add code can be resolved.

# -*-coding:ut-8-*-

5. Configure static file Statics

Writing in progress ...

  

ubuntu1404+django1.9+apache2.4 Deployment Configuration 2 configuration File Settings

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.