uwsgi

1、

uwsgi –http :8000 –wsgi-file test.py  测试uwsgi

  • http :8000:使用HTTP协议 8000端口
  • wsgi-file:加载指定的文件

2、uwsgi –http :8000 –module mysite.wsgi  测试django

杀死:killall -9 uwsgi

启动django:uwsgi uwsgi.ini

 

nginx

1、准备

# yum install gcc-c++
# yum install pcre
# yum install pcre-devel
# yum install zlib 
# yum install zlib-devel
# yum install openssl
# yum install openssl-devel

2、安装

下载:wget http://nginx.org/download/nginx-1.15.0.tar.gz
解压:tar -zxvf nginx-1.11.5.tar.gz
安装:make 和make install

3、开机自启

# cd /lib/systemd/system/
# vim nginx.service
[Unit]
Description=nginx 
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target


systemctl enable nginx.service    #设置自启动

systemctl start nginx.service    启动nginx

systemctl stop nginx.service    结束nginx

systemctl restart nginx.service    重启nginx

#验证:http://118.25.126.94/

配置

1、/user/local/nginx.conf配置

  #如果静态文件加载不成功,要加权限user root;
 server { listen
8888; server_name 118.25.126.94/; charset utf-8; location /media { alias /home/centos/python3.6.5/搭建个人博客/website/media; } location /static { alias /home/centos/python3.6.5/搭建个人博客/website/static; } location / { include uwsgi_params; uwsgi_pass 127.0.0.1:8000; } } }

2、uwsgi配置:在你的项目目录下创建一个ini文件,

 

 

  1 [uwsgi]
  2 #uwsgi监听的socket,一会配置nginx会用到
  3 socket = 127.0.0.1:8000
  4 #在app加载前切换到该目录,设置为django项目根目录
  5 chdir = /home/centos/python3.6.5/搭建个人博客/website
  6 #加载指定的python wsgi模块,设置为django项目的wsgi文件
  7 module = website.wsgi
  8 #启动一个进程来管理其他进程
  9 master = true
 10 #工作的进程数
 11 processes = 4
 12 #每个进程下的线程数量
 13 threads = 2
 14 #当服务器退出时,自动删除Unix socket文件
 15 vacuum = true
 16 #使进程在后台运行,并将日志写到指定的日志文件或者udp服务器
 17 daemonize = /home/centos/python3.6.5/搭建个人博客/website/uwsgi.log
~                                                                         

 

测试

 

版权声明:本文为xjmlove原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/xjmlove/p/9172908.html