部署

基于本地解释器

默认 uwsgi 基于 python3.6 解析器部署 wsgi 应用,其他python版本需要编译插件
操作:
安装或下载uwsgi 原码,编译 python38 插件

  1. # 源码编译 python3.8
  2. $ ./configure --prefix=/usr/local/python3 --enable-shared --enable-optimizations
  3. $ make altinstall
  4. # 软链接
  5. [root@localhost]# which python
  6. /usr/bin/python
  7. [root@localhost]# which python3
  8. /usr/local/bin/python3
  9. [root@localhost]# ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
  10. [root@localhost]# ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
  11. [root@localhost]# python --verison
  12. [root@localhost]# pip -V
  13. # 动态库异常
  14. [root@localhost]# python3 --version
  15. python3: error while loading shared libraries: libpython3.8.so.1.0:cannot open shared object file: No such file or directory
  16. [root@localhost]# find / -name libpython3.8.so.1.0
  17. /usr/local/python3/lib/libpython3.8.so.1.0
  18. [root@localhost]# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /usr/lib/
  19. or
  20. [root@localhost]# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /usr/lib64/
  21. # 编译插件
  22. $ cd /usr/src/uwsgi
  23. $ make PROFILE=nolang
  24. $ PYTHON=python3.8 uwsgi --build-plugin "plugins/python python38"
  25. $ mkdir -p /usr/lib/uwsgi/plugins
  26. $ cp python38_plugin.so /usr/lib/uwsgi/plugins/
  27. $ uwsgi --plugin python38 ...

测试 uwsgi

  1. $ pkill -9 uwsgi
  2. $ 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/