I am migrating from CentOS 7 to CentOS 8 with VirtualMin running on AMD Ryzen 9 server and sharing issues that I run into. Here is a next one:
mod_wsgi extension module is used to run Python scripts on a Virtual Server (so directly run .py scripts from a browser).
A - CENTOS 7 SETUP
In CentOS 7, I installed mod_wsgi via:
1 - yum install rh-python36 rh-python36-mod_wsgi
2 - cp /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so /lib64/httpd/modules
3 - cp /opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf /etc/httpd/conf.modules.d
4 - systemctl restart httpd
Next, is was possible to place the Python 3 scripts directly under /home/my-virtual-server.com. For example, place test.py in /home/my-virtual-server.com/python/test/test.py.
So the config part for this virtual server in /etc/httpd/conf/httpd.conf would look something like:
ServerName my-virtual-server.com
#added for Python via mod_wsgi
WSGIDaemonProcess test user=my-virtual-server.com group=my-virtual-server.com processes=1 threads=5
WSGIScriptAlias /test /home/my-virtual-server.com/python/test/test.py
<Directory /home/my-virtual-server.com/python>
WSGIProcessGroup test
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
#end for Python via mod_wsgi
Next the Python3 script test.py can be run via the browser:
http://my-virtual-server.com/test
The really big advantage of this setup was that all the Python scripts could be placed in the home directory of the Virtual Server. So if a backup was made of this website, all Python code was also backed up.
B - CENTOS 8 SETUP
In CentOS 8, I installed mod_wsgi via:
1 - yum install python3-mod_wsgi
2 - systemctl restart httpd
Next, is was NOT possible to place the Python 3 scripts directly under /home/my-virtual-server (Access denied error in browser). Instead, I was forced to place the Python 3 scripts under:
/var/www/html/
So the config part for this virtual server in /etc/httpd/conf/httpd.conf would look something like:
ServerName my-virtual-server.com
#added for Python via mod_wsgi
WSGIDaemonProcess test user=my-virtual-server.com group=my-virtual-server.com processes=1 threads=5
WSGIScriptAlias /test /var/www/html/python/test/test.py
<Directory /var/www/html/python/>
WSGIProcessGroup test
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
#end for Python via mod_wsgi
Next the Python3 script test.py can be run via the browser:
http://my-virtual-server.com/test
When doing a Re-Check in VirtualMin / CentOS 8, this limitation is clearly communicated via a warning:
“SuExec cannot be used to run PHP scripts in CGI or FCGId modes : The Suexec command on your system is configured to only run scripts under /var/www, but the Virtualmin virtual server home directory is /home. CGI scripts run as domain owners will not be executed.”
==> My question is if there is no solution or workaround that would allow me to place the Python 3 scripts under the home directory of the Virtual Server?
That would really simplify code organization and backups and migration of individual Virtual Servers within the VirtualMin eco system.