【问题标题】:mod_wsgi and virtualenv - Invalid command 'WSGIPythonHome'mod_wsgi 和 virtualenv - 无效的命令 'WSGIPythonHome'
【发布时间】:2014-11-25 20:27:35
【问题描述】:

期望的行为

我希望 Apache 使用安装在 virtualenv 中的 mod_wsgi,而不是依赖安装在系统级别的 mod_wsgi。我假设这是可能的,因为这就是我认为virtualenv 的用途,即创建孤立的环境。

当前行为

环境:Linux Mint 17

sudo /etc/init.d/apache2 start

AH00526: Syntax error on line 1 of /etc/apache2/sites-enabled/000-default.conf:
Invalid command 'WSGIPythonHome', perhaps misspelled or defined by a module not included
in the server configuration
Action 'configtest' failed.

/etc/apache2/sites-enabled/000-default.conf

WSGIPythonHome /var/www/html/ENV
WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    WSGIScriptAlias / /var/www/html/myapp/app.wsgi

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

我的尝试

如果我通过 Synaptic 包管理器在系统级别安装 mod_wsgi,那么一切都会按预期工作。

如果我在系统级别通过 Synaptic 包管理器 *卸载* mod_wsgi,并仅依赖通过 pipvirtualenv 中安装的 mod_wsgi,那么我会收到上述错误。

我一直在提到这个,但无法从中收集到任何针对此问题的特定解决方案:

https://code.google.com/p/modwsgi/wiki/VirtualEnvironments

【问题讨论】:

    标签: python-2.7 virtualenv mod-wsgi


    【解决方案1】:

    经过反思,我现在猜测mod_wsgi 是一个 Apache 模块,它不可能在 virtualenv 中运行,就像 Apache 不能在 virtualenv 中运行一样,因此@ 987654325@ 需要在系统级别安装才能正常工作。

    另见:

    Can I run Apache, mod_wsgi and MongoDB within virtualenv?

    这是我最终使用的配置:

    /etc/apache2/sites-enabled/000-default.conf

    WSGIPythonHome /var/www/html/ENV
    WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages:/var/www/html/wsgi
    <VirtualHost *:80>
    
        # for all content in static folder - css, js, img, fonts
        Alias /static/ /var/www/html/wsgi/static/
    
        # for rockmongo
        Alias /rockmongo /var/www/html/rockmongo
    
        <Directory /var/www/html/rockmongo>
            Order deny,allow
            Allow from all
        </Directory>
    
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        WSGIScriptAlias / /var/www/html/wsgi/application
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2012-01-29
      • 1970-01-01
      • 2020-01-29
      • 2018-10-14
      • 2016-04-10
      • 2020-02-10
      • 2012-07-30
      • 1970-01-01
      • 2017-02-18
      相关资源
      最近更新 更多