部署
基于本地解释器
默认 uwsgi 基于 python3.6 解析器部署 wsgi 应用,其他python版本需要编译插件
操作:
安装或下载uwsgi 原码,编译 python38 插件
# 源码编译 python3.8
$ ./configure --prefix=/usr/local/python3 --enable-shared --enable-optimizations
$ make altinstall
# 软链接
[root@localhost]# which python
/usr/bin/python
[root@localhost]# which python3
/usr/local/bin/python3
[root@localhost]# ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
[root@localhost]# ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
[root@localhost]# python --verison
[root@localhost]# pip -V
# 动态库异常
[root@localhost]# python3 --version
python3: error while loading shared libraries: libpython3.8.so.1.0:cannot open shared object file: No such file or directory
[root@localhost]# find / -name libpython3.8.so.1.0
/usr/local/python3/lib/libpython3.8.so.1.0
[root@localhost]# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /usr/lib/
or
[root@localhost]# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /usr/lib64/
# 编译插件
$ cd /usr/src/uwsgi
$ make PROFILE=nolang
$ PYTHON=python3.8 uwsgi --build-plugin "plugins/python python38"
$ mkdir -p /usr/lib/uwsgi/plugins
$ cp python38_plugin.so /usr/lib/uwsgi/plugins/
$ uwsgi --plugin python38 ...
测试 uwsgi
$ pkill -9 uwsgi
$ uwsgi --http-socket :5000 --plugin python38 --module wsgi:app --virtualenv /var/www/pythonmyadmin/myenv/
参考
https://gist.github.com/slav0nic/791d7ddd2c834479da126eb6fd16951a
https://stackoverflow.com/questions/65362467/uwsgi-cant-find-python3-plugin-open-python3-plugin-so-no-such-file-or-d
https://alan.ivey.dev/posts/2017/python-3-and-uwsgi-on-centos-7/
https://www.workaround.cz/howto-configure-nginx-php-python-uwsgi-letsencrypt-ssl-https-http2-centos7/
https://www.paulox.net/2019/03/13/how-to-use-uwsgi-with-python-3-7-in-ubuntu-18-x/
https://hackersandslackers.com/deploy-flask-uwsgi-nginx/