我用flask框架写好一个网站后,部署到了云服务器上,已经用gunicorn部署好了,但是只能访问程序设定的2000端口,现在想通过访问默认80端口,就能跳转到2000端口,我使用了nginx,但是当我配置好后发现怎么都不管用,具体如下
配置文件如下
server{
listen 80;
location / {
proxy_pass http://localhost:2000;
}
}
我将配置文件做了软链接,linux显示如下:
ll /etc/nginx/sites-enabled/bbs
/etc/nginx/sites-enabled/bbs -> /var/www/bbs/bbs.nginx
bbs.nginx就是配置文件,然后我重启nginx
server nginx restart
我接下来访问主页时出错了,主页显示403错误,主页后面的具体某一页显示404错误
也可能是因为关闭了gunicorn,因为当我手动开启gunicron时,代码如下
gunicorn wsgi --bind 0.0.0.0:2000 --pid /tmp/bbs.pid
这时候shell上只显示
[2018-05-20 01:12:31 +0800] [1311] [INFO] Starting gunicorn 19.8.1
[2018-05-20 01:12:31 +0800] [1311] [INFO] Listening at: http://0.0.0.0:2000 (1311)
[2018-05-20 01:12:31 +0800] [1311] [INFO] Using worker: sync
[2018-05-20 01:12:31 +0800] [1314] [INFO] Booting worker with pid: 1314
在这种情况下我没办法输入别的命令,只能按Ctrl+任意键退出,退出提示如下
[1] + 1311 suspended gunicorn wsgi --bind 0.0.0.0:2000 --pid /tmp/bbs.pid
这时候我才能输入别的命令,请大佬帮我指出错误或者给我这个小白点建议,不胜感激
后台运行命令,不影响终端输入,可以用
&
符号在最后。如:重启服务用service,不是server!
重启之前要用下面的指令检查配置文件是否正确:
启动之后要检查
/var/log/nginx/error.log
, 看有什么出错信息没有。