Ubuntu 16.04 Deployment Pypy+nginx+uwsgi+django (detail)

Source: Internet
Author: User
Tags virtual environment virtualenv

1, Nginx

install nginx before installing a python pip, do not use PyPy Pip, will easily destroy dependencies, difficult to repair,

sudo apt-get install Nginx

because, is automatically installed, so nginx configuration file in the/etc/nginx/sites-enabled/file directory under the default. Open directly from command VI, a, into insert mode, for editing. Because Ubuntu is not vim, so the upper and lower left and right arrow keys actually show the letter, H, J, K, L, is up and down, so first download Vim, in the editing.

sudo apt-get install vim--Download Vim

Vi/etc/nginx/sites-enabled/default--Open config file

Changes made to the configuration file

# The upstream component Nginx needs to connect to
About the configuration of Djjango upstream Django {server Unix:///Tmp/webvision.sock; # for a file socket#server127.0.0.1:8001; #For a Web port socket (we‘ll use this first)}server {
Link to index Home listen80Default_server;index index.html index.htm index.phpDefault.htmlDefault.htmDefault. php;# the domain name it would serveFor server_name. Shitac.netDefault192.168.21.31; # Substitute your machine‘s IP address or fqdncharset utf-8; root/var/www/html;# Max upload sizeclient_max_body_size 75M; # Adjust to taste
General configuration
Directly match the site root, through the domain name to visit the site home more frequently, using this will speed up the processing location/{Uwsgi_pass django;include/etc/nginx/uwsgi_params;} Location/media/ {alias/var/www/webvision2/media/;} Location/static/ {alias/ Var/www/webvision2/static/;} Location =/crossdomain.xml {root/var/www/html;} Location/live {root/var/www/ html;expires-1pic {root/var/www/ html;expires 30d;}}

/span>
2, pypy                                                                                                                                                     

Note: The official source of the run Uwsgi will be wrong,Google is saying that the official source is the static libpypy-c.so:cannot Open Shared object file

So I chose to install the PPA pypy

Installation commands

sudo add-apt-repository Ppa:pypy/ppa
sudo apt update
sudo apt install pypy

You may need a domestic source of PIP to increase the speed of PIP operation, can Baidu find a lot, I use the watercress

Vim ~/.pip/pip.conf//will copy the following in pip.conf    [global]    index-url = http:// Pypi.douban.com/simple     [Install]    trusted-host=pypi.douban.com
3, uwsgi                                                                                                                                                            

We first enter the PYPY environment and install the UWSGI in the PyPy environment.

Installing Uwsgi

Virtualenv-p/usr/bin/pypy PyPy--establishing the virtual environment of PyPy
SOURCE ~/pypy/bin/activate --Enter the environment
Pip Install Uwsgi--Install

After the download, you can change the Uwsgi configuration file,

[Uwsgi]socket=/tmp/Webvision.sock--Specify socket #这是实现应用nginx与uwsgi之间的通信 (very complicated stuff)Master=true--the main process starts true Processes=4-Start four process workEnable-threads =true-allows threads to be started in an embedded language. Pidfile=/tmp/webvision2_uwsgi.pid--Specify PID process file Daemonize= /var/log/webvision2/Uwsgi.log--uwsgi.log must be a log chdir= /var/www/Webvision2---project directory, if the site is more recommended Flasepythonpath= /var/www/Webvision2--Indicates the project path of the current application virtualenv=/home/kanbig/PyPy PyPy-home =/home/kanbig/PyPy PyPy-wsgi-file =/var/www/webvision2/lteadmin/wsgi.py--wsgi is the communication between Uwsgi and Djiango, which is the absolute path
4, djiango                                                                                                                                                  

Install Djiaogo need to enter the Djiango directory, has been configured in Webvision2 wsgi.py, so CD in

Install requirememts dependent libraries first

Pip Install-r requirements.txt

This last step is a lot of problems,pyFlake8 may need to reduce the file, the system prompts Pyflake8 "=1.6, etc. there are many problems, according to the error prompts each installation download on the line, here I only provide a reduction step

pip uninstall Pyflakespip Install pyflakes= =1.6

Final Start command

Uwsgi--ini uwsgi.ini    -elf|  grep Uwsgi--if there are four processes started on the sudo service nginx restart    -elf|grep nginx--nginx open input localhost no error on the line

Ubuntu 16.04 Deployment Pypy+nginx+uwsgi+django (detail)

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.