Question

Is WSGIScriptAlias the mount point of a mod_wsgi application analogous to a default file such as index.php or default.htm?

In other words, is this python file in the WSGIScriptAlias where I start my application (include files, etc.)

WSGIScriptAlias /myapp "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/www/wsgi-scripts/foobar.py"

<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/www/wsgi-scripts">
Order allow,deny
Allow from all
</Directory>

Side question, is this all I need to make a Python web application? Is this all the frameworks use, if they are on Apache?

Was it helpful?

Solution

It is not the same as a index.php or default.htm.

For those they would only generally be accessed when a URL request is made specifically against the directory that file is in, and the DirectoryIndex directive had been set to say to use that file/resource in that case. If there were other static files/resources in the same directory and the URL matched those explicitly, then they instead would be used. In either case, how the file is handled, that is a static file or as PHP code, it dictated by the file extension.

For any Alias/ScriptAlias/WSGIScriptAlias directive in Apache, where the last argument refers to a directory as in your case, it is saying that everything in the directory should be treated as a WSGI script file, regardless of the extension.

It is actually uncommon to have the last argument for WSGIScriptAlias refer to a directory as you are better off using a web framework and have it worried about dispatch to request handlers in code living outside of the exposed Apache directory. In that case, the last argument would be a single WSGI script file which is the entry point for the web application using the framework.

In other words, I wouldn't go down this path too much. Instead go grab a web framework such as Flask or Django and use it. Only use Apache as the jumping off point for the Python web application using the framework. Do not use multiple WSGI script files and use Apache as the dispatch mechanism as that can quickly lead to problems if you do not know what you are doing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top