I'm running CentOS 8.1 with Python 3.6.8, and Apache/2.4.37.
I'm new to mod_wsgi. I found this "hello world" example and got it to work:
The problem I'm having is that this appears to require each .py file to be added to its own .conf file to be added to conf.d, as seen in /etc/httpd/conf.d/helloworld.conf:
WSGIScriptAlias /helloworld /var/www/python/helloworld.py
<Directory /var/www/python/>
Order allow,deny
Allow from all
</Directory>
And to run on python (.py) scripts out of /var/www/python.
This is very inconvenient before it looks like each Python program needs to be hardcoded instead of running out of the /var/www/html directories. We have development in Python 2 where the .py files are executed in the same directory along with .html and .php files. Under CentOS 7 we just had an entry added to the httpd.conf to recognize all .py files and make sure they got executed by Python.
I see the author mentioned this was for security. Is there a way to do this still being secure, but so I don't have to gather up all the .py files on the server and make .conf files for it, as seen in this "hello world" example?
If my take on using mod_wsgi is completely wrong, please enlighten me.
The mod_wsgi also has
WSGIScriptAliasMatch
that could be useful in your case, e.g.If you don't require the shorter paths, you could also use
WSGIScriptAlias
for the whole folder:That would be equivalent to:
This is similar to how you'd use mod_python's Publisher Handler:
For more examples, please refer to mod_wsgi Configuration Guidelines