Django Nginx+uwsgi --- uwsgi测试

1.安装uwsgi

2.创建test.py文件,文件内容如下

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

3.测试 uwsgi 是否正常 ,在终端执行
uwsgi --http :8001 --wsgi-file /data/test.py

4.执行报错,报错内容如下

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

5.去解决问题=======================》》》
查看uwsgi安装位置,终端执行 :

      whereis uwsgi
执行结果为:
    uwsgi: /usr/sbin/uwsgi /usr/lib64/uwsgi /etc/uwsgi.d /etc/uwsgi.ini
定位原因为:
    上面两个uwsgi文件均缺失plugin插件,所以需要自行安装plugin插件:uwsgi-plugin-python 

6.安装 uwsgi-plugin-python
提示:安装之前需要先安装 uwsgi-plugin-common 安装步骤如下:

yum install uwsgi-plugin-common
yum install uwsgi-plugin-python

7.再次执行uwsgi --http :8001 --wsgi-file /data/test.py 依旧报同样错误
8.修改命令为:uwsgi --http-socket :8001 --wsgi-file /data/test.py执行结果如下:
uwsgi: unrecognized option ‘–wsgi-file’
getopt_long() error

这是因为: 需要在上面那些未识别选项前加上 –plugin python 来告诉uWSGI 我在使用 python 插件,对于后面那些选项你要用python 插件去解析

9.再次修改命令为:
uwsgi --http-socket :8001 --plugin python --wsgi-file /data/test.py

10.浏览器访问http://IP(XXXXX):8001/
终于 成功了!!!
最后附上终端显示内容

*** Starting uWSGI 2.0.16 (64bit) on [Fri Jun 22 14:39:45 2018] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 13 February 2018 02:48:03
os: Linux-3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
nodename: VM_0_7_centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root
detected binary path: /usr/sbin/uwsgi
dropping root privileges as early as possible
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3895
your memory page size is 4096 bytes
detected max file descriptor number: 100001
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8001 fd 3
dropping root privileges after socket binding
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 2.7.5 (default, Apr 11 2018, 07:36:10)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1013a90
dropping root privileges after plugin initialization
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1013a90 pid: 6852 (default app)
dropping root privileges after application loading
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 6852, cores: 1)

发布了61 篇原创文章 · 获赞 21 · 访问量 9128

猜你喜欢

转载自blog.csdn.net/xbean1028/article/details/102499669