There are many ways to build, record the use of the Docker deployment process, the future reference 1. Build Docker Environment
Install Docker, slightly
Port mapping external 82 to 80
Docker pull Python
run-itd-p 82:80--name yyst 6bf7a4fa2d45 Docker exec-it yyst
Bash
2. Install service, pack git, pull code
Copy URL from Https://github.com/584807419/YYST pull code, green button
Apt-get update
apt-get install git
apt-get install vim apt-get install nginx
pip install uwsgi
CD/ var/
mkdir www
cd www
git clone https://github.com/584807419/YYST.git
3. Installation dependencies, file migration
When you install a dependency package with PIP, the default access is https://pypi.Python.org/simple/, and the pipy mirrors provided by domestic vendors are currently available:
http://pypi.douban.com/watercress
http://pypi.mirrors.ustc.edu.cn/simple/China University of Science and Technology
Configures the specified mirror source and creates the. Pip folder under the current user directory
mkdir ~/.pip
Then create the pip.conf file in the directory to fill in:
[Global]
Trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
CD Yyst
pip install-r packages.txt
python manage.py makemigrations python manage.py
migrate
python manage.py collectstatic
4. Configure nginx UWSGI configuration file, run
Vi/etc/nginx/sites-available/yysy_nginx.conf
server {
listen ;
server_name 127.0.0.1;
CharSet Utf-8;
Client_max_body_size 75M;
Location/{
include uwsgi_params;
Uwsgi_pass unix:///var/www/yyst.sock
}
}
Create a soft connection
sudo ln-s/etc/nginx/sites-available/yysy_nginx.conf/etc/nginx/sites-enabled/yysy_nginx.conf
To kill the original default in sites-enabled.
test Configuration syntax issues
sudo service nginx configtest or/path/to/nginx-t reboot
Nginx server: C25/>sudo service Nginx Reload or sudo service nginx restart or/path/to/nginx-s reload
Vi/var/www/yyst_uwsgi.ini
# django-related Settings
[Uwsgi]
# http =:80
socket =/var/www/yyst.sock
# The base directory (full path
chdir =/var/www/yyst
# Django s Wsgi file
module = Yyst/yyst.wsgi
# process-related Settings
# Master
Master = True
# Maximum number of worker processes
Processes = 4
# ... with appropriate Permissions-may is needed
chmod-socket = 664 # Clear
Environment on exit
Vacu Um = True
cd/var/www/
Uwsgi–ini Yyst_uwsgi.ini
Visit: http://116.196.98.152:83/job/pyjob/
5. Other modes of Operation
There are multiple ways to develop the environment without UWSGI, you can also direct debug way Python manage.py runserver 86 demo and run code
You can also forward 80 requests to 86 ports using the Nginx reverse proxy
The reverse proxy is suitable for many occasions, and load balancing is the most common usage.
When multiple Web servers are deployed on a single host, and you need to be able to access these Web servers on port 80 simultaneously, you can use the Nginx reverse proxy feature: Listen for all requests with nginx on port 80, and forward rules based on the forwarding rule (more commonly, by URI) Forward to the corresponding Web server.
For example, there are webmail, webcom, and Webdefault three servers running on Portmail, portcom, Portdefault ports, and to achieve access to these three Web servers from 80 ports, you can run Nginx on 80 ports, It then forwards the request under/mail to the webmail server, forwards the request under/com to the webcom server and forwards all other requests to the Webdefault server.
Assuming the server domain name is example.com, the corresponding Nginx HTTP configuration is as follows:
HTTP {
server {
server_name example.com;
location/mail/{
proxy_pass http://example.com:protmail/;
}
location/com/{
proxy_pass http://example.com:portcom/main/;
}
Location/{
proxy_pass http://example.com:portdefault;
}
}
}
The above configuration forwards requests (both get and POST requests are forwarded) according to the following rules:
Forward the request under http://example.com/mail/to the http://example.com:portmail/
Forward the request under http://example.com/com/to the http://example.com:portcom/main/
Forward all other requests to http://example.com:portdefault/
It is to be noted that in the above configuration, the proxy settings for Webdefault are not specified, and the proxy server settings for webmail and webcom are URI-specific (respectively/and/main/).
If the proxy server address is with a URI, this URI will replace the URI part that the location matches.
If the proxy server address does not have a URI, it is forwarded to the proxy server with the full request URL.
Forwarding examples for the above configuration:
http://example.com/mail/index.html-> http://example.com:portmail/index.html
http://example.com/com/index.html-> http://example.com:portcom/main/index.html
Http://example.com/mail/static/a.jpg-> http://example.com:portmail/static/a.jpg
Http://example.com/com/static/b.css-> Http://example.com:portcom/main/static/b.css
Http://example.com/other/index.htm-> http://example.com:portdefault/other/index.htm
The code above Yyst the project using the configuration of this method
server {
listen ;
server_name 127.0.0.1;
CharSet Utf-8;
Client_max_body_size 75M;
Location/{
include uwsgi_params;
Uwsgi_pass Unix:///var/www/yyst.sock;
Proxy_pass http://127.0.0.1:85
}
}
Container Use related knowledge:
Http://www.runoob.com/docker/docker-run-command.html
Https://yeasy.gitbooks.io/docker_practice/content/network/port_mapping.html
Nginx Server installation and configuration files detailed:
https://segmentfault.com/a/1190000002797601