"""创建uwsgi.ini文件
# uwsgi.ini file
[uwsgi]
# Django-related settings
# django项目运行的端口号 使用uwsgi+nginx的时候使用
socket = 127.0.0.1:8808
# django项目的根目录,同名目录的外层(项目绝对路径的第一层路径)
chdir = /home/project/luffyapi/
# django项目同名目录内层自动生成的wsgi.py的路径,如果你的项目叫luffyapi,就填luffyapi.wsgi
module = luffyapi.wsgi
# 指定虚拟环境,如果没有使用虚拟环境可以不用指定 输入cdvirtualenv跳转虚拟环境 pwd
home = /root/.virtualenvs/luffy
# 开启主进程
# process-related settings
# master
master = true
# 最大进程数量
# maximum number of worker processes
processes = 2
# 停止uwsgi时自动清理
# ... with appropriate permissions - may be needed
# chmod-socket = 664
# clear environment on exit
vacuum = true
# 指定后台输出日志信息的文件,如果遇到不能正常使用,可以使用cat /var/log/uwsgi_log.log查看
报错信息
daemonize = /var/log/uwsgi_log.log
# 指定运行时候的pid文件,也可以用来停止进程, uwsgi --stop /var/run/uwsgi_pid.log
pidfile = /var/run/uwsgi_pid.log
-------------------------------------------------------------------------------------
1)进行uwsgi服务配置,内容如下
>: vim /home/project/luffyapi/luffyapi.xml
127.0.0.1:8808
/home/project/luffyapi/
luffyapi.wsgi
4
uwsgi.log
4)去向Nginx配置目录,备份配置,完全更新配置:填入下方内容
>: vim /usr/local/nginx/conf/nginx.conf
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name 127.0.0.1; # 改为自己的域名,没域名修改为127.0.0.1:80
charset utf-8;
location / {
root /home/html; # html访问路径
index index.html; # html文件名称
try_files $uri $uri/ /index.html; # 解决单页面应用刷新404问题
}
}
# 新增的server
server {
listen 8000;
server_name 127.0.0.1; # 改为自己的域名,没域名修改为127.0.0.1:80
charset utf-8;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8808; # 端口要和uwsgi里配置的一样
uwsgi_param UWSGI_SCRIPT luffyapi.wsgi; #wsgi.py所在的目录名+.wsgi
uwsgi_param UWSGI_CHDIR /home/project/luffyapi/; # 项目路径
}
}
}
"""