python - Mod_wsgi 问题 - 此处不允许使用 LoadModule

标签 python .htaccess ubuntu mod-wsgi

我想在我的服务器 - Ubuntu 服务器上测试 mod_wsgi。
我的 .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: LoadModule not allowed here

我的 apache conf (/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/
这有什么问题吗?

最佳答案

来自 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中使用它。

关于python - Mod_wsgi 问题 - 此处不允许使用 LoadModule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9425785/

相关文章:

python - 使用Scrapy爬取隐藏数据

python - Python中矩阵元素的双重求和

apache - 调试.htaccess

.htaccess 500 设置 ExpiresActive 时的内部服务器错误

ruby-on-rails - 缺少 Rails 2.3.11 gem。请 `gem install -v=2.3.11 rails` ,

python - 从英语到 Pig Latin 的翻译

python - Softbank Pepper 机器人与 Naoqi - 使用 Python 进行摄像头直播延迟

php - 是否可以使用在 URL 中传递的值来查询数据库,并使用 mod_rewrite 将查询结果写入 URL?

python - 使用 Firefox 驱动程序在 Ubuntu LTS 上运行 Headless Webdriver 测试

ubuntu - 有没有办法在 Puppeteer for Firefox 中使用代理?