简体   繁体   English

如何修复Apache服务器中的导入ssl错误(Windows)

[英]How to fix import ssl error in Apache server(Windows)

I'm trying to design a RESTful API with a Flask app using mod_wsgi on an Apache server, and I'm getting an error with importing the ssl module in the Apache server. 我试图设计一个使用Apache服务器上mod_wsgi的烧瓶中应用一个RESTful API,而我得到一个错误,在Apache服务器导入SSL模块。 I have installed Apache 2.4 from https://www.apachelounge.com/download/ , and mod_wsgi using pip, configured it in the Apache server. 我已经从https://www.apachelounge.com/download/安装了Apache 2.4,并使用pip安装了mod_wsgi,在Apache服务器中配置了它。

I created a simple Flask app: 我创建了一个简单的Flask应用程序:

    from flask import Flask   '
app = Flask(__name__)
    @app.route("/")
    def hello():
        return "Hello World"
    if __name__ == "__main__":
        app.run()

I created a web.wsgi file: 我创建了一个web.wsgi文件:

    import sys 
sys.path.insert(0, 'C:/Users/chant/myapp')
from final_app import app as application

and used it to configure a virtual host for the Flask App, by pasting the following code in http-vhosts.conf: 并通过在http-vhosts.conf中粘贴以下代码,使用它为Flask应用程序配置虚拟主机:

<VirtualHost *:5000>
    ServerName  localhost
    WSGIScriptAlias / "C:/Users/chant/myapp/web.wsgi"
    DocumentRoot "C:/Users/chant/myapp"
ErrorLog "C:/Users/chant/myapp/logs/error.log"
    CustomLog "C:/Users/chant/myapp/logs/access.log" common

My error log shows: 我的错误日志显示:

    File "c:\\programdata\\anaconda3\\Lib\\ssl.py", line 98, in <module>\r
    import _ssl             # if we can't import it, let the error propagate\r
ImportError: DLL load failed: The specified module could not be found.\r

Though I tried testing the import module and it ran in python, though it is not importing in the Apache server. 虽然我尝试测试导入模块并且它在python中运行,但它没有在Apache服务器中导入。

If anyone has any suggestions, it would be most appreciated. 如果有人有任何建议,将非常感谢。

I noticed later that an important part of the deployment of the Flask app is that Python should be installed for all users, else Apache server is not able to import the ssl module. 后来我注意到Flask应用程序部署的一个重要部分是应该为所有用户安装Python,否则Apache服务器无法导入ssl模块。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM