我正在尝试安装一个可以承载Python应用程序的Ubuntu服务器。它有nginxweb服务器。我对这些技术还比较陌生
我可以设置nginx来提供静态html文件,但是在设置Python时遇到了问题。我得到的是它找不到页面(例如404错误)
我一直在遵循以下URL上的步骤: https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04
我的示例应用程序与他们的示例非常相似,只是我将其命名为app.py并将其复制到文件夹“/srv/www/gobid/live”
我的“app.py”代码看起来像:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World From Digital Ocean"
在“/etc/nginx/sites enabled/”中,我有一个配置文件,如下所示:
server {
listen 80;
root /srv/www/gobid/live;
index index.html index.htm test.html;
# Make site accessible from http://localhost/
# server_name localhost;
server_name 10.220.200.11;
access_log /var/log/nginx/gobid.access.log main;
error_log /var/log/nginx/gobid.error.log;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
#include uwsgi_params;
#uwsgi_pass /srv/www/gobid/live/myapp.sock;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /hello/ {
include uwsgi_params;
# uwsgi_pass 127.0.0.1:9090;
}
}
我曾尝试创建套接字,但它导致nginx不再提供静态页面。我已经设置了url“10.220.200.11”来指向这个站点
当我键入“http://10.220.200.11/”时,静态页面的服务是正确的
我想让“http://10.220.200.11/hello/”返回app.py提供的内容(在本例中,它会说“Hello World From Digital Ocean”),但它会说找不到文件(静态页面和app.py位于同一目录中)
目前没有回答
相关问题 更多 >
编程相关推荐