linux下通过pip安装最新uwsgi 通不过测试的时候,要用socket不能直接http

linux下通过pip安装最新uwsgi

 版权声明:欢迎转载 https://blog.csdn.net/feinifi/article/details/79354115

通过yum install uwsgi 安装的uwsgi在进行测试的时候,发现版本是2.0.15,但是启动uwsgi测试的时候报参数错误,后来改用pip安装(先yum remove uwsgi删除老的uwsgi)就成功了。uwsgi安装完成之后的样子

安装pip

  1.  
    wget https://bootstrap.pypa.io/get-pip.py
  2.  
    python ./get-pip.py

安装uwsgi,一个干净的linux系统安装uwsgi过程中,会遇到以下两个错误。

  1.  
    Exception: you need a C compiler to build uWSGI
  2.  
    ----------------------------------------
  3.  
    Failed building wheel for uwsgi
  4.  
    Running setup.py clean for uwsgi
  5.  
    Failed to build uwsgi
  6.  
    Installing collected packages: uwsgi
  7.  
    Running setup.py install for uwsgi ... error

解决办法:yum install gcc-*

另外一个错误:

fatal error: Python.h: No such file or directory

解决办法:yum install python-devel

安装成功的打印信息:

  1.  
    [root@VM_68_155_centos ~]# pip install uwsgi
  2.  
    Collecting uwsgi
  3.  
    Using cached uwsgi-2.0.16.tar.gz
  4.  
    Building wheels for collected packages: uwsgi
  5.  
    Running setup.py bdist_wheel for uwsgi ... done
  6.  
    Stored in directory: /root/.cache/pip/wheels/3a/e7/aa/24207bb9d885fe11fab3f7ad7d9d80c538a423d98494d43fd7
  7.  
    Successfully built uwsgi
  8.  
    Installing collected packages: uwsgi
  9.  
    Successfully installed uwsgi-2.0.16
  10.  
    [root@VM_68_155_centos ~]#

编辑一个简单的测试文件hello.py:

  1.  
    def application(env,start_response):
  2.  
    start_response( '200 OK',[('Content-Type','text/html')])
  3.  
    return "Hello,world"

启动uwsgi : uwsgi --http-socket :80 --wsgi-file hello.py

  1.  
    [root@VM_68_155_centos ~]# /usr/bin/uwsgi --http-socket :80 --wsgi-file hello.py
  2.  
    *** Starting uWSGI 2.0.16 (64bit) on [Fri Feb 23 15:31:16 2018] ***
  3.  
    compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 23 February 2018 07:28:20
  4.  
    os: Linux-3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017
  5.  
    nodename: VM_68_155_centos
  6.  
    machine: x86_64
  7.  
    clock source: unix
  8.  
    detected number of CPU cores: 1
  9.  
    current working directory: /root
  10.  
    detected binary path: /usr/bin/uwsgi
  11.  
    !!! no internal routing support, rebuild with pcre support !!!
  12.  
    dropping root privileges as early as possible
  13.  
    uWSGI running as root, you can use --uid/--gid/--chroot options
  14.  
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
  15.  
    *** WARNING: you are running uWSGI without its master process manager ***
  16.  
    your processes number limit is 3895
  17.  
    your memory page size is 4096 bytes
  18.  
    detected max file descriptor number: 100001
  19.  
    lock engine: pthread robust mutexes
  20.  
    thunder lock: disabled (you can enable it with --thunder-lock)
  21.  
    uwsgi socket 0 bound to TCP address :80 fd 3
  22.  
    dropping root privileges after socket binding
  23.  
    uWSGI running as root, you can use --uid/--gid/--chroot options
  24.  
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
  25.  
    Python version: 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
  26.  
    *** Python threads support is disabled. You can enable it with --enable-threads ***
  27.  
    Python main interpreter initialized at 0x7d64c0
  28.  
    dropping root privileges after plugin initialization
  29.  
    uWSGI running as root, you can use --uid/--gid/--chroot options
  30.  
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
  31.  
    your server socket listen backlog is limited to 100 connections
  32.  
    your mercy for graceful operations on workers is 60 seconds
  33.  
    mapped 72904 bytes (71 KB) for 1 cores
  34.  
    *** Operational MODE: single process ***
  35.  
    WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x7d64c0 pid: 6557 (default app)
  36.  
    dropping root privileges after application loading
  37.  
    uWSGI running as root, you can use --uid/--gid/--chroot options
  38.  
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
  39.  
    *** uWSGI is running in multiple interpreter mode ***
  40.  
    spawned uWSGI worker 1 (and the only) (pid: 6557, cores: 1)

测试uwsgi-server

猜你喜欢

转载自www.cnblogs.com/timye607/p/10454391.html