版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38570967/article/details/81841289
step1 安装python , uwsgi及nginx
ptyon安装教程
https://blog.csdn.net/weixin_38570967/article/details/81811415
uwsgi安装教程
https://blog.csdn.net/weixin_38570967/article/details/81841202
nginx安装教程
https://blog.csdn.net/weixin_38570967/article/details/81811788
step2# 编辑 /etc/nginx/sites-available/下的default文件 ,并在统计目录下创建uwsgi_params文件
upstream django{
#server 127.0.0.1:8080;
server unix:/project/vcmt/car/car/mysite.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
#proxy_pass http://127.0.0.1:8080;
uwsgi_pass django;
include uwsgi_params;
}
}
uwsgi_params的内容为
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_ADDR $server_addr;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
step3 #在django项目目录下创建mysite_uwsgi.ini文件(uwsgi启动时从这个文件获取参数 文件位置和名字任意命名)
[uwsgi]
#plugins = python3.6
# Django-related settings
# the base directory (full path)
chdir = /project/vcmt/car/car
# Django's wsgi file
module =car.wsgi
# the virtualenv (full path)
home = /project/vcmt/
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = /project/vcmt/car/car/mysite.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
step4#启动uwsgi 和nginx
通过配置文件启动uwsgi (退出虚拟环境启动uwsgi。由于mysite_uwsgi.ini中指定了虚拟环境的位置,会自动加载虚拟环境中依赖的库)
uwsgi --ini /project/vcmt/car/car/mysite_uwsgi.ini