用于https配置的UWSGI无法正常工作

时间:2019-05-24 18:25:27

标签: uwsgi libssl

UWSGI版本2.0.18

Openssl- 1.0.2k次

Python 2.7

获取错误:

uwsgi: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory

1 个答案:

答案 0 :(得分:0)

每当我们进行pip安装uWSGI时,它都会自动绑定到openssl库。

但是请确保已安装openssl和openssl-devel软件包。

我尝试了以下版本:

Python- 3.6

UWSGI- 2.0.18

命令:

创建虚拟环境并安装flask和uWSGI:

virtualenv -p /usr/bin/python3.6 testing
source testing/bin/activate
pip install flask
pip install uWSGI

创建证书:

openssl genrsa -out foobar.key 2048
openssl req -new -key foobar.key -out foobar.csr
openssl x509 -req -days 365 -in foobar.csr -signkey foobar.key -out foobar.crt

创建示例Python文件:foobar.py

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

运行uWSGI:

uwsgi --shared-socket 0.0.0.0:443 --uid roberto --gid roberto --https =0,foobar.crt,foobar.key --wsgi-file foobar.py

确保不要与虚拟环境中安装的uWSGI和root用户混淆。

遵循文档:

https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html