在学习flask部署一节时,需要用到uwsgi和nginx。根据官方文档安装完uwsgi和nginx后,做了一个测试。测试代码如下:
test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return "<h1>Hello, World!</h1>".encode('utf-8')
运行uwsgi --http :9090 --wsgi-file test.py
后可以正常浏览http://localhost:9090.
配置nginx:
example
server {
listen 80;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
}
}
启动nginx和uwsgi后浏览http://localhost后启动的是nginx默认页面,而带9090端口则正常显示hello world。
我试过直接修改sites-enabled/default结果也一样,conf.d文件夹里没有任何文件。
请问如何修改配置?看了很多相关问题,但还是没能找到具体的解决方案,所以重新提问,谢谢。
使用端口通信
使用socket文件通信
你配置完nginx的conf文件以后是否有重启?