Python WSGI处理程序直接在Apache .htaccess中,而不在VirtualHost中 [英] Python WSGI handler directly in Apache .htaccess, not in VirtualHost

查看:122
本文介绍了Python WSGI处理程序直接在Apache .htaccess中,而不在VirtualHost中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何拥有一个Python Bottle服务器:

I know how to have a Python Bottle server:

import os
from bottle import route, template, default_app
os.chdir(os.path.dirname(__file__))

@route('/hello')
def hello():
    return template('Hello world')

application = default_app()

使用WSGI运行,并使用Apache进行如下配置:

run with WSGI, configured like this with Apache:

<VirtualHost *:80>
  ServerName example.com
  <Directory />
    AllowOverride All
    Require all granted
  </Directory>
  WSGIScriptAlias / /var/www/wsgi_test/app.wsgi
</VirtualHost>

是否可以直接在.htaccess 中进行WSGI配置?

Is it possible to do the WSGI configuration directly in the .htaccess?

推荐答案

我刚刚找到了

I just found the doc, and it seems that the answer is no, sadly:

使用mod_cgi托管CGI应用程序时,可以使用ScriptAlias指令来完成.对于mod_wsgi,该指令改名为WSGIScriptAlias:

When using mod_cgi to host CGI applications, this would be done using the ScriptAlias directive. For mod_wsgi, the directive is instead called WSGIScriptAlias:

WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

此伪指令只能出现在主要的Apache配置文件中.该指令可以在服务器范围内使用,但通常会放置在特定站点的VirtualHost容器中.不能在位置",目录"或文件"容器指令中使用它,也不能在".htaccess"文件中使用.

This directive can only appear in the main Apache configuration files. The directive can be used at server scope but would normally be placed within the VirtualHost container for a particular site. It cannot be used within either of the Location, Directory or Files container directives, nor can it be used within a ".htaccess" file.

(重点是我的)

这篇关于Python WSGI处理程序直接在Apache .htaccess中,而不在VirtualHost中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆