Avoid Virtualmin feature "PHP Versions" in Debian 8/9

I reported this bug in Issues section, but it was closed and marked as fixed because someone decided I was looking for support. Pretty sad.

Here is the report. I installed Debian Jessie from scratch in a virtual machine then added Virtualmin. I created two virtual hosts both using default PHP version 5.6. I added ondrej/php repository and I was able to install more PHP versions: 7.0, 7.1 and 7.2 and managed to use every of them with my virtual hosts.

Now I set up a virtual host to use PHP 5.6 and the other one to use PHP 7.2. Everything works as expected. All changes made manually in Terminal.

Virtualmin has a feature in “Server Configuration” section called “PHP Versions”. For the first virtual host “Default HTML directory” I changed Version from 5.6.39 to 7.0.33 then clicked [Save Versions] button. From now on if I want to access the website in browser all php files are becoming downloadable. I went back to “PHP Versions” section and changed from 7.0.33 to 5.6.39 and saved. Configuration was not reverted to initial stage. All php files are not processed in browser and still downloadable.

Using this feature, website part of your Virtual Server is becoming compromised. Even I am an advanced system engineer I was not able to find what was going wrong without dedicating a couple of hours. So I tried reporting this and hopping to get help from Virtualmin team. In fact I wanted to know what is happening in background after pressing [Save Versions] button, what files are changed, Apache modules disabled/enabled, and so on.

Someone decided this is a support request. His solution was reading this page: https://www.virtualmin.com/documentation/web/multiplephp. This is a basic level. It teaches you about installing PHP versions and using “PHP Sections” in Virtualmin. I am sorry to say but this is not a solution, in fact it is the start of your nightmare even for a advanced Virtualmin user. Just follow these instructions and your website will become public as php files. Good job.

I will try finding a solution for this issue. Please do not change “PHP Versions” in Virtualmin for your virtual hosts if you are using Debian Jessie or Stretch.

i am guessing you folks are using the Ubuntu ppa to extend ubuntu’s php capabilities…unfortunately this places Ubuntu out of its default state…once you “fix” it the next time you run apt to update virt it is going to overwrite with it’s configs…now you have a broken mess in terms of PHP and Apache. Extending PHP in cent is much easier because remi’s repo doesn’t mess with any Apache files…unlike Ubuntu ppa. I have a cent 7 server that has php 5.4, 5.5, 5.6, 7.0 all at the same time…easily…because the third party repos do not screw with the apache configs. upgrading sql in cent puts me in the same mess with databases as upgrading php does in ubuntu. I would HIGHLY suggest if you are using 16.04 to NOT use the ppa to try to get anything other than php 7.0 until Ubuntu releases official packages for it. I am waiting for the 18.04 branch to become officially supported then i am going to backup virt…pave the server…and then restore into it’s base default PHP 7.2.x series. If you want faster updates use Debian but you will be reloading every 18-24 months.

@hescominsoon: It is mentioned in the post the issues are related to Debian but it could be extended to Ubuntu too. The initial message was a warning. I am sorry to say but your message did not provide any solution for a Virtualmin user, it is more a “general speaking” post.

For all interested here is how I solved the problem: https://www.virtualmin.com/node/60155. All servers I done these changes are running now in production. Only one was affected by a short delay till I fixed the issue.

This was done manually. Virtualmin is not doing the full job when using [PHP Versions] feature. Once all steps mentioned in that post are done anyone can switch between php versions without any issues. Switching from php versions in FCGI is a known issue.

I hope the Virtualmin team will fix it in next versions.