【问题标题】:mac os + apache 2.4.33 + python 3.7.2 + django 2.1.5 + mod_wsgi 4.6.5 (Site can't be reached)mac os + apache 2.4.33 + python 3.7.2 + django 2.1.5 + mod_wsgi 4.6.5(无法访问站点)
【发布时间】:2019-06-25 02:17:13
【问题描述】:

python 从 2.x 升级到 3.7.2 后,我在运行服务器时遇到问题(无法访问站点)我们的服务器配置:

  • Mac OS 10.13.6(High Sierra)
  • Apache 2.4.33 自定义安装
  • Python 3.7.2(Brew 安装 python3)
  • Django 2.1.5(通过 pip 在 python 3 env 中安装)
  • mod_wsgi 4.6.5(通过 pip 在 python 3 env 中安装)

我在 httpd.conf 文件中添加了以下两行(mod_wsgi-express module-config),删除了 python 2.7 引用:


LoadModule wsgi_module "/../MASP_ENV3/lib/python3.7/site-packages/mod_wsgi/server/mod_wsgi-py37.cpython-37m-darwin.so"
 
WSGIPythonHome "/../MASP_ENV3" 

也在 httpd-vhosts.conf 中:

WSGIDaemonProcess mysite.com processes=2 threads=15 display-name=%{GROUP} python-home=/Library/WebServer/Documents/MASP_ENV3 python-path=/Library/WebServer/Documents/mysite

WSGIProcessGroup mysite.com
WSGIScriptAlias / /Library/WebServer/Documents/mysite/wsgi.py

重新启动服务器后,当我们在浏览器中点击 URL 时,页面会继续加载一段时间(2-5 分钟),然后显示“无法访问站点”

如果有人能指导我提出宝贵的建议,那就太好了。谢谢!

【问题讨论】:

    标签: python django macos apache mod-wsgi


    【解决方案1】:

    apache 错误日志中报告了什么?

    您能否将参数 request-timeout 添加到 WSGIDaemonProcess 并将其设置为较低的值,例如 30 秒?进行此类更改后,您会在大约 30 秒内收到“站点未到达”还是仍需要 2-5 分钟?

    wsgi 是否配置为在任何地方写入日志?你能看到请求到达 python 应用程序吗?

    很抱歉将问题写成答案,但我仍然没有添加 cmets 所需的级别。

    【讨论】:

    • Apache 的 error_log 文件中没有记录任何内容。目前,日志级别设置为警告。将其更改为调试和交叉验证。无论如何感谢您的建议。
    【解决方案2】:

    问题是没有在python3系统安装目录中创建虚拟环境。我按照这个文档解决了这个问题:
    * https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html#location-of-the-virtual-environment

    另外,我与 mod_wsgi 作者的详细对话在这里: https://github.com/GrahamDumpleton/mod_wsgi/issues/396

    【讨论】:

      猜你喜欢
      • 2012-07-10
      • 2019-07-16
      • 2020-03-05
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      • 2011-08-23
      • 2021-09-22
      • 1970-01-01
      相关资源
      最近更新 更多