Apache/httpd 错误:无效命令‘WSGIPythonHome’

Apache/httpd 错误:无效命令‘WSGIPythonHome’

问题:

我的 Apache/httpd 服务器无法启动。journalctl -xe显示:

Feb 27 01:50:12 localhost.localdomain httpd[4398]: AH00526: Syntax error on line 355 of /etc/httpd/conf/httpd.conf:
Feb 27 01:50:12 localhost.localdomain httpd[4398]: Invalid command 'WSGIPythonHome', perhaps misspelled or defined by a module not included in the server configuration
Feb 27 01:50:12 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Feb 27 01:50:13 localhost.localdomain kill[4399]: kill: cannot find process ""
Feb 27 01:50:13 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
Feb 27 01:50:13 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.

httpd -S揭示了:

AH00526: Syntax error on line 355 of /etc/httpd/conf/httpd.conf:
Invalid command 'WSGIPythonHome', perhaps misspelled or defined by a module not included in the server configuration

眼镜

  • CentOS 7(这是在 Ubuntu 18.10 主机上运行的虚拟机)
  • rh-python36已安装
  • rh-python36-mod_wsgi-4.5.18-1.el7.x86_64已安装
  • python 虚拟环境创建于/var/www/web-virt-env

httpd配置文件

WSGIPythonHome /var/www/web-virt-env
WSGIPythonPath /var/www/html/somewebsite

<VirtualHost *:80>

    ServerName awebsite.com
    DocumentRoot /var/www/html/somewebsite
    WSGIDaemonProcess somewebsite1 python-home=/var/www/web-virt-env
    WSGIProcessGroup somewebsite1
    WSGIScriptAlias / /var/www/html/somewebsite/somewebsite/wsgi.py

    <Directory /var/www/html/somewebsite/somewebsite>
            Require all granted
    </Directory>

    Alias /static /var/www/html/somewebsite/static
    <Directory /var/www/html/somewebsite/static>
            Require all granted
    </Directory>

</VirtualHost>

预期输出:

我预计执行以下代码后网站会启动:systemctl start httpd

我怀疑这rh-python36-mod_wsgi-4.5.18-1.el7.x86_64并没有被“发现”,但我不确定这在幕后是如何运作的。

我该怎么做才能解决这个问题?或者至少,我接下来应该采取哪些步骤来解决这个问题?

答案1

尤里卡!

我可以通过添加以下内容来解决这个问题httpd.conf我在问题中显示的补充(所以,就在之前)WSGIPythonHome /var/www/web-virt-env

LoadModule wsgi_module /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so

答案2

我把它放在虚拟主机之前

LoadModule wsgi_module /usr/lib64/apache2/modules/mod_wsgi.so
<VirtualHost 69.16.201.27:443>
     ServerName blue.domain.com
     ....

答案3

安装 apt 包libapache2-mod-wsgi-py3帮助过我

相关内容