One subsite giving PHP download while others work properly

OS type and version: Ubuntu Linux 20.04.3
Webmin version: 1.984
Virtualmin version: 6.17-3
Related products version: PHP 7.4.3

My server has around 6 subsites. One of those subsites that has an alias is giving a download of PHP files instead of executing them. All the other sites are working fine.

This is almost always caused by having mod_php installed (usually in the php or php7.4-php or similar) package. You should not have mod_php installed.

How could we avoid mod_php when upgrading the PHP form PHP 7.2 to PHP 7.4? Ubuntu 18.04 comes with PHP 7.2.

Don’t install it!

To repeat what I said above: usually in the php or php7.4-php or similar package. That’s mod_php. Just don’t install the damned thing. That’s all there is to not installing mod_php.

We have documentation for installing additional PHP versions, which will also guide you correctly (i.e. by not telling you to install mod_php). Multiple PHP Versions – Virtualmin

If you follow random guides on the internet, you will get yourself into a mess.

Thanks a lot you for that link.

I don’t have it installed.
Attached is the list of packages I have installed.
Installed Packages.log (68.3 KB)

Surprising! OK, in that case try the following:

  1. Validate Virtual Servers.
  2. Change to a different execution mode for a problem site, even if only temporarily, just to see if behavior changes.
  3. Check for leftovers from having mod_php installed. Specifically, any Apache config files that have SetHandlers for php files, other than the ones setup in the Virtualmin-managed vhosts. If you have installed any web apps from the Ubuntu repositories (e.g. phpmyadmin) this is very likely to be a problem.

Switching to FPM made the site work. Is there something in the docs somewhere that describes all the differences and why you would pick one over the other.

FPM is the right mode for nearly everyone. You can pretty much ignore everything else.

mod_php should never be used by anyone. It is inherently insecure in a shared hosting environment, it is inefficient (wildly so). We do not install mod_php by default, and the only answer to questions about mod_php I’ll give is “don’t use mod_php and uninstall it so it doesn’t break your other sites when it inevitably gets updated and screws up the handlers”.

fcgid+suexec is OK, but has more moving parts than FPM and is thus more fragile, it isn’t as well-supported by the upstream PHP devs (FPM is a core PHP component), and is probably less efficient for the average deployment (there are circumstances where it’s better, some where it’s worse, but if you don’t know fcgid is better for you, just use FPM).

CGI+suexec is only there for debugging/troubleshooting or very tiny one-file scripts that never need more than one or two running at once (like a mail form or something silly like that), and shouldn’t be considered for production deployment of complicated apps.

Basically, if you’re running PHP, FPM is the only execution mode that matters. It’s the default on newer distros and in Virtualmin 7 for all distros.

Oh, and to be clear, merely switching modes can make an app work, if what broke it was SetHandlers from mod_php or something else (like an app installed via apt or something else) screwing it up. Virtualmin would have detected the bogus SetHandlers and added some additional configuration to remove it for the virtual server in question. Switching back would probably also continue to work. But, since FPM is the recommended execution mode, there’s no reason to do so.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.