美文网首页
2019-05-12

2019-05-12

作者: baixuetang11 | 来源:发表于2019-05-12 12:06 被阅读0次

nginx使用验证,分别在windows,ubuntu下运行(目前是验证python高效开发实战第166页)

windows中

windows下载nginx (http://nginx.org/en/download.html) (https://blog.csdn.net/kingscoming/article/details/79042874)

解压后保存在D:\nginx-1.14.2

步骤如下https://blog.csdn.net/kingscoming/article/details/79042874

1.下载Nginx文件包解压免安装

http://nginx.org/

进入目录开启使用 start nginx 开启

D:\tangpython\test_uwsgi>python2 wsgi_server.py开启

然后在浏览器中127.0.0.1:8080即可运行成功,返回hello world

ubuntu中

遇到nginx每次启动出现错误,需要将nginx重装:

2019-05-12删除nginx(ubuntu) https://chubuntu.com/questions/51656/nginx-cant-purge-on-ubuntu-16-04.html

编辑:

由于问题无法以这种方式解决且问题是由 nginx-core 引起的,您可以尝试通过执行以下操作手动修复问题:

sudo apt -f remove nginx-core

为此: sudo apt -f remove nginx-full

然后从 sudo apt autoremove --purge 。

开始,完成上述步骤   

然后重新安装nginx

sudo apt-get install nginx

sudo service nginx start

service nginx status

在windows中cmd把文件上传到ubuntu中

D:>pscp -P 22 D:\tangpython\webapp.py ubuntu@139.199.66.32:/home/ubuntu

D:>pscp -P 22 D:\tangpython\wsgi_server.py ubuntu@139.199.66.32:/home/ubuntu

然后在ubuntu中使用python wsgi_server.py,然后浏览器中139.199.66.32:8080即可访问成功,返回hello world

在ubuntu中使用uwsgi完成如上功能:(只需要webapppy即可,不需要wsgi_server.py,因为ubuntu中有wsgi server)

安装 pip install uwsgi

uwsgi --http :9090 --wsgi-file webapp.py

  --http后要用空格和冒号隔开,在http后加“空格冒号端口“”,例如:uwsgi --http :9090 --wsgi-file webapp.py

然后使用浏览器139.199.66.32:9090即可访问成功,返回hello world

相关文章

网友评论

      本文标题:2019-05-12

      本文链接:https://www.haomeiwen.com/subject/skccaqtx.html