Ubuntu Server 14.04.2 LTS configure Nginx + Uwsgi + Django

Source: Internet
Author: User
Tags install django pip install django

Ubuntu Server 14.04.2 LTS configure Nginx + Uwsgi + Django

This article describes how to configure Nginx + Uwsgi + Django in Ubuntu Server 14.04.2 LTS.

0. The purpose is to integrate small and exquisite Nginx and Django through uwsgi

1. Prepare for Python 2.7.8 @ ubuntu server 14.04.2

2. Install Django (pip is used here, And easy_install is also supported)
sudo pip install django==1.8

3. Install Nginx
sudo apt-get install nginx

4. Install uwsgi
sudo apt-get install uwsgi

5. Create a Django project + app
>>python django-admin.py startproject cloud_shield
>>cd cloud_shield
>>python manage.py startapp cloud_proxy

6. Add the code and configuration diagrams respectively.
(Only the configuration diagrams of the files to be modified are provided here)

1. First, complete the django app, that is, write a simple method to reply to the request in cloud_proxy/views. py.

Add app and static_URL in settings. py

And add the pair (r ^ $ 'cloud _ proxy. views. cs_receive_request ') in urls. py.

In fact, none of the above will go into detail for those familiar with Django, but it is still necessary to let everyone know the details, no matter whether they have the foundation or not ~
  1. The configuration of django is completed above, and nginx is configured below; the configuration file cloud_shield_nginx.conf in the root directory of the project

This file also needs to provide a soft connection under the nginx directory to let nginx know the configuration file. This soft link must be configured, after configuration, you can also view it in sites-enabled using vi;
>> sudo ln -s /home/bw/cloud_shield/cloud_shield_nginx.conf /etc/nginx/sites-enabled/

There is also a small detail in/etc/nginx. the first line starting with conf has a user www-data; this should be changed to the user's current system user; (it would be better if a user with a small permission is customized for the server ~)

  1. Finally, configure uwsgi

Errors such as 502 may occur during the intermediate configuration process. The solution is as follows:
When system services such as nginx cannot be started:>>tail /var/log/syslog
When an internal server error occurs:>>tail ~/bw/cloud_shield/uwsgi/uwsgi.log
Server check error:
>>nginx -c some_conf_file
Only nginx files can be checked here.

Finally, the entire project tree is shown below (the folder inside is the final result, and many files are manually created by yourself)

Finally, the Nginx tree is (mainly with a soft link ):

The last result of the last dns server configuration is:

In fact, there are a lot of small details to be aware of, and I cannot do it here, but the general direction and method of solving the problem are put here ~

If you have any questions, please do not hesitate to inform us ~

 

Deploy Nginx + uWSGI + Flask in Ubuntu 12.04

You should use Nginx + uWSGI

UWSGI + Nginx deploy Flask Web Applications

Deployment of Django + Nginx + uWSGI

Deploy Python applications in Nginx + uWSGI in Linux

Install Nginx + uWSGI + Django on Ubuntu Server 12.04

CentOS 5.5 + Nginx 0.8.50 + uWSGI + Django 1.2.3 deploy the Django Project

Nginx details: click here
Nginx: click here

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.