centos7上安装nginx+uwsgi搭建项目

*安装nginx

yum instal  nginx
  • 使用pip安装uwsgi
pip install uwsgi
  • 新建配置文件
mkdir /etc/uwsgi
vim /etc/uwsgi/uwsgi.ini
  • 配置uwsgi
[uwsgi]
socket = 127.0.0.1:9090
master = true         
wsgi-file=/var/www/html/python/test.py
#vhost = true          
no-site = true        
workers = 2           
reload-mercy = 10     
vacuum = true        
max-requests = 1000   
limit-as = 512
buffer-size = 30000
pidfile = /var/run/uwsgi9090.pid    
daemonize = /var/log/uwsgi9090.log
  • 配置test.py文件
mkdir /var/www/html/python/
vim test.py

写文件

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"
  • 配置nginx
vim /etc/nginx/conf.d/python.conf

插入下面

server {
    listen       8090;
    server_name 127.0.0.1;

    location / {
    include  uwsgi_params;
        uwsgi_pass  127.0.0.1:9090;        
    }
}
  • 启动
systemctl start nginx
uwsgi /etc/uwsgi/uwsgi.ini
  • 访问,在浏览器上输入10.104.15.150:9090(此时ip换成你的linux机器ip)


    1524623005.jpg

如此,则成功了,接下来你可以愉快地使用python进行项目开发了

你可能感兴趣的:(centos7上安装nginx+uwsgi搭建项目)