环境
uwsgi
UWSGI 下载
pip install uwsgi
UWSGI 配置
[uwsgi]
socket=0.0.0.0:7777
http=0.0.0.0:7777
http-socket=0.0.0.0:7777
pythonpath=/home/ubuntu/apt_epiboly
wsgi-file=/home/ubuntu/apt_epiboly/run.py
callable=app_main
master=true
processes = 1
threads = 10
buffer-size = 65536
stats=/home/ubuntu/apt_epiboly/config/uwsgi.status
pidfile=/home/ubuntu/apt_epiboly/config/uwsgi.pid
reload-mercy = 1
worker-reload-mercy = 1
enable-threads = true
harakiri=180
vacuum = true
lazy-apps = true
pythonpath=/usr/lib/python2.7/dist-packages
pythonpath=/usr/local/lib/python2.7/dist-packages
nginx
nginx 配置
该配置适用uwgi采用socket方式 该配置支持部署多个项目
user root;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
sendfile on;
keepalive_timeout 65;
client_max_body_size 500M;
server {
listen 80;
server_name localhost;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
location / {
try_files $uri $uri/ /index.html;
root /home/ubuntu/apt/dist;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Headers X-Requested-With;
if ($request_method = OPTIONS){
return 200;
}
}
location /api/ {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8888;
uwsgi_send_timeout 600;
uwsgi_connect_timeout 600;
uwsgi_read_timeout 600;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 82;
server_name localhost;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
location / {
try_files $uri $uri/ /index.html;
root /home/ubuntu/apt_epiboly/dist;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Headers X-Requested-With;
if ($request_method = OPTIONS){
return 200;
}
}
location /api/ {
include uwsgi_params;
uwsgi_pass 127.0.0.1:7777;
uwsgi_send_timeout 600;
uwsgi_connect_timeout 600;
uwsgi_read_timeout 600;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 81;
server_name localhost;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
location / {
try_files $uri $uri/ /index.html;
root /home/ubuntu/apt_probe/dist;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Headers X-Requested-With;
if ($request_method = OPTIONS){
return 200;
}
}
location /api/ {
include uwsgi_params;
uwsgi_pass 127.0.0.1:6666;
uwsgi_send_timeout 600;
uwsgi_connect_timeout 600;
uwsgi_read_timeout 600;
proxy_pass http://127.0.0.1:6666/api/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
启动
启动uwsgi
路径参考自己的uwsgi.ini配置文件
nohup uwsgi --ini /home/apt/config/uwsgi.ini >/home/apt/apt.log 2>&1 &
启动nginx
systemctl start nginx
访问
浏览器输入部署服务器ip和端口号
|