阿里云centOS安装uwsgi之后测试失败的原因

问题一:

「报错:
open("./python_plugin.so"): No such file or directory [core/utils.c line 3724]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: Permission denied!!! 」

[jojo@iZ8vb9xlla82qbtg3sg06gZ dailyfresh]$ uwsgi --plugin python --http :8080 --wsgi-file uwsgitest.py
open("./python_plugin.so"): No such file or directory [core/utils.c line 3724]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
*** Starting uWSGI 2.0.18 (64bit) on [Thu Jun 11 13:28:30 2020] ***
compiled with version: 8.3.1 20190507 (Red Hat 8.3.1-4) on 10 June 2020 10:18:59
os: Linux-4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020
nodename: iZ8vb9xlla82qbtg3sg06gZ
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home/jojo/www/dailyfresh
detected binary path: /usr/local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 6873
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8080 fd 7
spawned uWSGI http 1 (pid: 22868)
uwsgi socket 0 bound to TCP address 127.0.0.1:46775 (port auto-assigned) fd 6
Python version: 3.6.8 (default, Nov 21 2019, 19:31:34)  [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x120dd60
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 ***
failed to open python file uwsgitest.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 22867, cores: 1)

「解决思路」

方法一:

在测试uwsgi之前,你需要做好了以下工作
前置条件:我用的阿里云服务器创建的实例,使用的centOS8 + python3.6.8

基本条件

  • 1.使用的python版本为3.6+
  • 2.在正确的项目目录下创建了test.py文件(注意return的字节是否按照网上说的区分开了python2和python3)
  • 3.输入了正确的命令启动test.py文件
  • 4.你的阿里云服务器实例支持你创建的端口(阿里云默认的安全组只支持80,443,22,3389,80这几个端口,你可以检查一下是否有你设置的端口)

都检查了,还是报错。

方法二:管用
首先查询是否已存在uwsgi,并卸载:
rpm -qa|grep uwsgi
yum remove -y uwsgi*

若之前是pip 安装的话,执行:
pip uninstall uwsgi

重新安装:
Ubuntu 的Python3 :

apt-get install -y uwsgi-plugin-python3
注:这里可能还有个所有可用的plugin:sudo apt-get install uwsgi-plugins-all

centos环境:

sudo yum install -y uwsgi-plugin-python
查看 uwsgi 服务是否启动:
uwsgi --ini uwsgi.ini
可以正常运行了,但是浏览器中依然访问不到。

问题二:!!! no internal routing support, rebuild with pcre support !!!

detected binary path: /xxx/xxx/.virtualenvs/h1/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!

「解决方案」
注意操作的先后顺序:

1.卸载uwsgi
pip uninstall uwsgi
#注意此时卸载,pip会有缓存留在系统里

2.安装pcre支持库
yum install pcre pcre-devel pcre-static

3.继续安装uwsgi,不走pip缓存
pip install uwsgi -I --no-cache-dir

#启动uwsgi,已经没有“ !!! no internal routing support, rebuild with pcre support !!! ”报错了

上面不管用,使用下方

首先查询是否已存在uwsgi,并卸载:
rpm -qa|grep uwsgi
yum remove -y uwsgi*

若之前是pip 安装的话,执行:
pip uninstall uwsgi

重新安装:
Ubuntu 的Python3 :

apt-get install -y uwsgi-plugin-python3
注:这里可能还有个所有可用的plugin:sudo apt-get install uwsgi-plugins-all

centos环境:

sudo yum install -y uwsgi-plugin-python
查看 uwsgi 服务是否启动:
uwsgi --ini uwsgi.ini
可以正常运行了,但是浏览器中依然访问不到。

问题三:安装报错
原因:错误是由于默认安装时CFLAGS是开启的状态,需要在安装前将该选项关闭,采用如下安装方式。
解决:CFLAGS=-Wno-error pip3 install uWSGI

查看CentOS版本号

rpm -qi centos-release

Name        : centos-release
Version     : 8.1
Release     : 1.1911.0.9.el8
Architecture: x86_64
Install Date: Thu 11 Jun 2020 11:56:06 AM CST
Group       : System Environment/Base
Size        : 25430
License     : GPLv2
Signature   : RSA/SHA256, Fri 13 Mar 2020 06:15:30 AM CST, Key ID 05b555b38483c65d
Source RPM  : centos-release-8.1-1.1911.0.9.el8.src.rpm
Build Date  : Fri 13 Mar 2020 03:15:30 AM CST
Build Host  : x86-02.mbox.centos.org
Relocations : (not relocatable)
Packager    : CentOS Buildsys 
Vendor      : CentOS
Summary     : CentOS Linux release file
Description :
CentOS Linux release files
activate激活某个环境
source activate python34 # for Linux & Mac
# 退出虚拟环境
source deactivate python34 # for Linux & Mac
# 删除一个已有的环境
conda remove --name python34 --all

你可能感兴趣的:(阿里云centOS安装uwsgi之后测试失败的原因)