python+ nginx + django + uwsgi 之 (三) 安装 uwsgi

一,安装uwsgi

1.1 安装

[root@iZwz948fbj8fd5kmzmmaiyZ ~]# pip install uwsgi
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting uwsgi
  Downloading http://mirrors.aliyun.com/pypi/packages/a2/c9/a2d5737f63cd9df4317a4acc15d1ddf4952e28398601d......
Successfully installed uwsgi-2.0.17.1

1.2 创建软链接

# 先看看uwsgi所在位置
[root@iZwz948fbj8fd5kmzmmaiyZ ~]# find / -name uwsgi
/usr/local/python27/bin/uwsgi

# 创建软链接
[root@iZwz948fbj8fd5kmzmmaiyZ ~]# ln -s /usr/local/python27/bin/uwsgi /usr/bin/uwsgi

1.2 测试(可跳过)

在app目录创建一个test.py

[root@iZwz948fbj8fd5kmzmmaiyZ ~]# cd /home/wwwroot/files.**.com/wandehua/
[root@iZwz948fbj8fd5kmzmmaiyZ wandehua]# ls
db.sqlite3  manage.py  wandehua  weidoo
[root@iZwz948fbj8fd5kmzmmaiyZ wandehua]# vi test.py

test.py 代码:

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return 'Hello Python'

项目跑起来:uwsgi --http 0.0.0.0:8001 --wsgi-file test.py

[root@iZwz948fbj8fd5kmzmmaiyZ wandehua]# uwsgi --http 0.0.0.0:8001 --wsgi-file test.py
*** Starting uWSGI 2.0.17.1 (64bit) on [Tue Jan 15 17:42:58 2019] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 15 January 2019 09:19:43
......
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 1516, cores: 1)

访问:http://127.0.0.1:8001 (或外网域名/ip:8001,阿里云记得在安全组里开8001端口)页面显示:

猜你喜欢

转载自blog.csdn.net/wan271920545/article/details/86496146