我有一个腾讯云的服务器,使用flask,uwsgi,nginx来搭建一个服务器。
按照网上的方法是这样写的。
我的nginx配置是
我修改的是这个文件 /etc/nginx/sites-enabled/default
1
2
3
4
5
6
7
8
9
10
11
12
13
14 server {
listen 80;
server_name 111.230.140.182;
charset utf-8;
client_max_body_size 75M;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8080;
uwsgi_param UWSGI_PYTHON /usr/bin/python;
uwsgi_param UWSGI_CHDIR /home/ubuntu/project/test;
uwsgi_param UWSGI_SCRIPT test:app ;
}
}
然后我的uwsgi.ini配置是这么写的:
1
2
3
4
5
6
7
8
9
10 [uwsgi]
socket = 127.0.0.1:8080
plugins = python
chidir = /home/ubuntu/project/test
wsgi-file = /home/ubuntu/project/test/test.py
callable = app # 程序变量名
protocol=http
module=test
processes = 4
threads = 2
然后我的test.py是这么写的:
1
2
3
4
5
6
7 from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return '<h1> hello world! </h1>'
if __name__ =='__main__':
app.run(debug=True)
我先是运行nginx,然后在运行uwsgi,但是会报这个错误:
mapped 332288 bytes (324 KB) for 8 cores
Operational MODE: preforking+threaded
unable to load app 0 (mountpoint=”) (callable not found or import error)
unable to find “application” callable in file /home/ubuntu/project/test/test.py
unable to load app 0 (mountpoint=”) (callable not found or import error)
我也查了不少文章都没有解决我这个问题。特来求教!
谢谢大家!!