安装这里就不多说,直接配置问题及所遇到问题总结
django 项目 manage.py目录新建uwsgi.ini文件
uwsgi配置
[uwsgi]
socket = 127.0.0.1:9000 # uwsgi直接访问用http,nginx访问用socket
http= 127.0.0.1:9000
chdir = /usr/local/www/项目目录
wsgi-file = /usr/local/www/项目目录/项目目录/wsgi.py
module = 项目目录.wsgi
buffer-size = 65536
callable=app
master = true
processes = 4
threads=2
master =True
vacuum = true
pidfire= uwsgi.pid
plugins = python36
logto = /usr/local/www/项目目录/logs/uwsgi.log
nginx配置
server {
listen 8001 default_server;
server_name 127.0.0.1;
access_log /usr/local/www/项目目录/logs/access.log;
error_log /usr/local/www/项目目录/logs/error.log;
location / {
include /usr/local/nginx/conf/uwsgi_params;
uwsgi_pass 127.0.0.1:9099; #必须和uwsgi中的设置一致
}
}
遇到错误:
1、Internal Server Error
出现这种错没有配置wsgi.py
wsgi-file = /usr/local/www/项目目录/项目目录/wsgi.py
这个文件类似于入口文件,命令创建django会自动创建
2、502错误
查看uwsgi日志,502大部分uwsgi问题或者nginx等问题
tail -f /usr/local/www/项目目录/logs/uwsgi.log
– unavailable modifier requested: 0 –
– unavailable modifier requested: 0 –
这个是需要安装uwsgi-plugin-python
yum install uwsgi-plugin-python
然后uwsgi.ini文件添加配置
plugins = python 此处注意:plugins = python36 我配置的是python36,之前直接写python3会报错:
/usr/lib/uwsgi/plugins/python_plugin.so: cannot open shared object file: No such file or directory
ll /usr/lib64/uwsgi/
总用量 476
-rwxr-xr-x. 1 xxx cgi_plugin.so
-rwxr-xr-x. 1 xxx http_plugin.so
-rwxr-xr-x. 1 xxx python36_plugin.so
-rwxr-xr-x. 1 xxx python_plugin.so