【问题标题】:Mod_wsgi issue - LoadModule not allowed hereMod_wsgi 问题 - 此处不允许加载模块
【发布时间】:2012-02-24 05:20:44
【问题描述】:

我想在我的服务器上测试 mod_wsgi - Ubuntu 服务器。
我的 .htaccess:

LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /home/apps/hello.py

我的hello.py:

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

Apache 返回:

.htaccess: 此处不允许加载模块

我的 apache 配置文件(/etc/apache2/sites-enabled/000-default):

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

.htaccess 在 /var/www/sub/
这有什么问题?

【问题讨论】:

  • 你能在 .htaccess 内做到这一点吗?

标签: python .htaccess ubuntu mod-wsgi


【解决方案1】:

来自 Apache 文档:

Description:    Links in the object file or library, and adds to the list of active modules
Syntax: LoadModule module filename
Context:    server config
Status: Extension
Module: mod_so

因为它的上下文是Server config,所以不能在.htaccess中使用。

【讨论】:

  • 所以,我需要在 /etc/apache2/sites-enabled/000-default 中完成这一切吗?
  • 把它放在etc/apache2/apache2.conf(Apache主配置文件)
  • IOW,也必须在任何虚拟主机之外。 Linux Apache 发行版通常有一个名为 mods-available 的目录,其中包含每个模块类型的文件,LoadModule 就在其中。查看您的发行版的文档。
  • @GrahamDumpleton 你说得对,我忘了,这是更好的主意。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-25
  • 2011-08-30
  • 2021-02-05
  • 2018-08-24
  • 1970-01-01
相关资源
最近更新 更多