Python WSGI handler directly in Apache .htaccess, not in VirtualHost

不问归期 提交于 2019-12-11 14:29:05

问题


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()

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>

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


回答1:


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

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

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.

(emphasis mine)



来源:https://stackoverflow.com/questions/59079366/python-wsgi-handler-directly-in-apache-htaccess-not-in-virtualhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!