The server that I've been upgrading/updating has pages using php and python. I've rewritten the python based pages using the Flask framework and apache is configured using wsgi:
<VirtualHost *:443>
ServerName my_fake_site
...
AliasMatch ^\/((?:flask_dir1|flask_dir2).*)\.((css|php|png)$((?:\?.*)?)) /var/www/html/app/$1.$2
AliasMatch ^\/(.*)\.(css|html|php|png) /var/www/html/$1.$2
WSGIDaemonProcess main_proc processes=8 python-home=/var/www/html/venv
WSGIScriptAlias / /var/www/html/wsgi.py
<Directory /var/www/html/>
WSGIProcessGroup main_proc
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
SSLEngine on
...
</VirtualHost>
WSGIPythonPath /var/www/html
WSGIPythonHome /var/www/html/venv
On the old server, urls pointing to directories default to index.php
using the DirectoryIndex
option (set in another conf file). On the new server, I get an "internal server error" message and a 500 response code in the error log.
So ultimately the question is, how do I configure apache to serve both pages handled by php and pages handled by python? (Note: there are a few pages handled by php in the flask directories)
EDIT: I added another AliasMatch
line that seems to do what I want. I was also able to remove 'php' from the second AliasMatch
line:
AliasMatch ^\/((?:flask_dir1|flask_dir2).*)\.((css|php|png)$((?:\?.*)?)) /var/www/html/app/$1.$2
AliasMatch ^\/(.*)\.(css|html|png) /var/www/html/$1.$2
AliasMatch ^\/((?:php_dir1|php_dir2).*) /var/www/html/$1
As mentioned in my edit, the AliasMatch
directive worked. From the documentation, this allows Apache to host static files, which I guess also includes php files.