Nginx Project Deployment

Source: Internet
Author: User

1. Concept
1. Django Project (web App)
2. Web Services
1, Nginx
2. Apache
Lnmp Linux Nginx MySQL Python/php/perl
Linux Apache MySQL Python/php/perl
3, Uwsgi
is a simple and common interface between Web servers and web frameworks
2. Single project Deployment (Nginx+uwsgi+django)
1. Make sure the Django Project works
2. Installing Nginx
1. Installation: sudo pip3 install Nginx
2, start: Sudo/etc/init.d/nginx restart
3. Verification: 127.0.0.1:80
3, Installation Uwsgi
1. Installation: sudo pip3 install Uwsgi
2. Verify (Start Django Project directly with Uwsgi)
Uwsgi--http:9998--chdir/home/tarena/myproject/fruit/--module Fruit.wsgi
4. Deployment
1. Configure Uwsgi (config file)
1, mkdir Uwsgi
2, Cd/home/tarena/uwsgi
3, VI Fruit_uwsgi.ini
1. Setup and Nginx communication port
Socket = 127.0.0.1:8001
2. Project path
ChDir =/home/tarena/myproject/fruit
3. wsgi.py Path
Wsgi-file = fruit/wsgi.py
4. Number of processes
processes = 4
5. Number of threads
Thread = 2
6, this project occupies Uwsgi port
Stats = 127.0.0.1:8081
2. Configure Nginx (config file)
1, Sudo-i
2, cd/etc/nginx/sites-enabled/
3, VI project_nginx.conf
server{
Listen 8201; #浏览器访问项目的端口
server_name fruit.com;
CharSet Utf-8;
Client_max_body_size 75M;
location/static{
Alias/home/tarena/myproject/fruit/static
}
# and Uwsgi communication, 1, nginx under Uwsgi_params file 2, port
Location/{
Include Uwsgi_params;
Uwsgi_pass 127.0.0.1:8001;
}

}
4. Copy the Uwsgi_params file to the project directory
sudo cp/etc/nginx/uwsgi_params/home/tarena/myproject/fruit
5. Restart Nginx Service
Sudo/etc/init.d/nginx restart
3. Collect static files
1. settings.py file, add path
Static_root = '/home/tarena/myproject/fruit/static/'
2. Collect static files
Python3 manage.py collectstatic
4. Uwsgi Startup Project
Uwsgi--ini Fruit_uwsgi.ini
3. Multi-Project deployment
1, Uwsgi: Each project needs to create a separate UWSGI configuration file, choose a different port
2, nginx configuration file, 1 can, add server{}
Item 2: Personal blog
Browser Access port: 8202, Listen 8202
Uwsgi and Nginx communication ports: 8002,socket=127.0.0.1:8002
UWSGI occupancy Port: 8082


Nginx Project Deployment

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.