问题
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