Django production Environment Deployment-logging Nginx+uwsgi+django

Source: Internet
Author: User
Tags install django

These days have been studying the deployment of Django production environment, read a lot of articles, are written very well, sometimes just the environment is not the same, there are a lot of problems in the configuration process, such as:

UWSGI---module has not been running, the addition of--file parameters can be ...

----Pro-Test can run-----

1. Install Django and create a project to ensure that the Python manage.py runserver 0.0.0.0:8080 can start normally


2. Install UWSGI,

Write a test.py on your machine

# test.py
DEF application (env, Start_response):
Start_response (' K OK ', [(' Content-type ', ' text/html ')])
Return "Hello World"
Then execute the shell command:

Uwsgi--http:8001--file test.py
To visit a webpage:

http://127.0.0.1:8001/

See if there's Hello World on the Web


3. Test whether Uwsgi and Django can be combined to run

Uwsgi--http:8000--chdir/opt/app/django-1.9.2/django/madking/--file wsgi.py

4. Configuration Uwsgi and Nginx combination

NGINX.CONF configuration:

server {
Listen 53385;
server_name localhost;

#charset Koi8-r;

#access_log Logs/host.access.log Main;
Access_log/opt/app/django-1.9.2/django/madking/access_log;
Error_log/opt/app/django-1.9.2/django/madking/error_log;

Location/{
root HTML;
Uwsgi_pass 127.0.0.1:3400;
Include/usr/local/nginx-1.7.12/conf/uwsgi_params; # The Uwsgi_params file you installed
Index index.html index.htm;
}
location/static {

root/opt/app/django-1.9.2/django/madking; # your Django project ' s static files-amend as required
}
#error_page 404/404.html;

# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}


Created under the Django Project: Madking_uwsgi.ini
Madking_uwsgi.ini file
[Uwsgi]

Socket = 127.0.0.1:3400
# django-related Settings
# The Django project directory (full path)
ChDir =/opt/app/django-1.9.2/django/madking
# Django ' s Wsgi file
File = wsgi.py

# process-related Settings
# Master
Master = True
# Maximum number of worker processes
processes = 2

Threads = 2
Max-requests = 6000

# ... with appropriate Permissions-may is needed
Chmod-socket = 664
# Clear Environment on exit
Vacuum = True
Daemonize =/opt/app/django-1.9.2/django/madking/uwsgi.log
----------------------------------------------------------------------------

Start Uwsgi--ini/opt/app/django-1.9.2/django/madking/madking_uwsgi.ini


Restart Nginx./nginx-s Reload

Django production Environment Deployment-logging Nginx+uwsgi+django

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.