您的位置:首页 > 运维架构 > Nginx

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

2016-09-02 18:54 706 查看
买了个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没有防火墙,可以直接访问,若是其他系统,访问不了的话,请自行判断是否需要关闭防火墙
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Django python