python django nginx从零开始搭建一个web网站系列1

来源:互联网 发布:微信公众号商城源码 编辑:程序博客网 时间:2024/04/30 12:04

买了个vps

系统之前是centos7,发现太素了,换成了ubuntu

ubuntu自带python3 以及python2 


系统没有pip3

如提示,apt-get install python3-pip

即可装好pip3


然后指定安装django1.8.1版本

pip3 install django==1.8.1

即可


然后查看uwsgi 

提示这样


选一个python3的版本

apt-get install uwsgi-plugin-python3

然后写个 test.py文件

#test.py

def application(env, start_response):

    tart_response('200 ok', [('Content-Type','text/html')])

    return [b'Hello Word']

注意 好多教程都是python2的,在python3里面是return [b"Hello word"]


然后起服务,uwsgi --http :8001 --wsgi-file /root/OBJ/atom/test.py

报错

uwsgi: option '--http' is ambiguous; possibilities: '--http-socket' '--http-socket-modifier2' '--http-socket-modifier1'getopt_long() error

root@cloud:~/OBJ/atom# uwsgi --http :8001 --wsgi-file /root/OBJ/atom/test.py

uwsgi: option '--http' is ambiguous; possibilities: '--http-socket' '--http-socket-modifier2' '--http-socket-modifier1'

getopt_long() error


加上-socket

root@cloud:~/OBJ/atom# uwsgi --http-socket :8001 --wsgi-file /root/OBJ/atom/test.py

uwsgi: unrecognized option '--wsgi-file'

getopt_long() error


再加

root@cloud:~/OBJ/atom# uwsgi --http :8001 --wsgi-file /root/OBJ/atom/test.py


OK 测试程序跑通


因为ubuntu没有防火墙,可以直接访问,若是其他系统,访问不了的话,请自行判断是否需要关闭防火墙

0 1
原创粉丝点击