1. 首先利用配置文件启动nginx。
命令: nginx -c /usr/local/nginx/conf/nginx.conf
重启服务: service nginx restart
2. 快速停止或关闭Nginx:nginx -s stop
3. 正常停止或关闭Nginx:nginx -s quit
4. 配置文件修改重装载命令:nginx -s reload
server { server_name localhost ; listen 80; location /static/ { alias /var/www/api/laowai_panda/static/; } location /media/ { alias /var/www/api/laowai_panda/media/; } location / { include uwsgi_params; #uwsgi_pass unix:/run/uwsgi/laowai_panda.sock; uwsgi_pass 127.0.0.1:8000; } #listen 443 ssl; # managed by Certbot #ssl_certificate /etc/letsencrypt/live/laowaipanda.com/fullchain.pem; # managed by Certbot #ssl_certificate_key /etc/letsencrypt/live/laowaipanda.com/privkey.pem; # managed by Certbot #include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot #ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot }
[uwsgi] # 配置服务器的监听ip和端口 socket = 127.0.0.1:8000 # 配置项目目录 chdir = /var/www/api/laowai_panda # 配置入口模块(/home/administrator/PyPros/uWSGI_test/wsgi.py模块下的application函数为入口函数) #module = wsgi:application wsgi-file = laowai_panda/wsgi.py # 开启master, 将会多开一个管理进程, 管理其他服务进程 master = True # 服务器开启的进程数量 processes = 4 # 服务器进程开启的线程数量 threads = 4 # 以守护进程方式提供服, 输出信息将会打印到log中 daemonize = wsgi.log # 退出的时候清空环境变量 vacuum = true # 进程pid pidfile = uwsgi.pid
启动uWSGI, 并指定加载那个配置文件. uwsgi --ini wsgi.ini 停止uWSGI, 如果你的配置文件中并没有pidfile = uwssgi.pid配置选项,那么需要使用下面方式停止服务器: killall -s INT /django_environ/bin/uwsgi 如果您指定了pidfile配置选项,那么可用下面方式停止服务器: uwsgi --stop uwsgi.pid