Change PHP Version on existing server

I have two virtual servers that I need to revert back to PHP 5.4 and can’t get them to change. They are existing servers. I can create a server with version 5.4, but I can’t change it once it is created.I have tried Server Configuration -> PHP Versions several times, but it changes nothing. Running CentOS Linux 7.5.1804 with Nginx. Version 7.1.33 is the default for both servers.

For the existing virtual servers, if you change PHP script execution mode from FPM to FCGId via Virtualmin | Server Configuration | Website Options, you might be able to select PHP 5.4 via Virtualmin | Server Configuration | PHP Versions

Well, that got it to change, but it went in the wrong direction. It is now defaulting to 7.3.

Yes, that’s how Virtualmin functions: the highest available version of PHP is selected by default. In case another version of PHP is preferred, it can be manually specified by selecting it from the dropdown box at Virtualmin | Server Configuration | PHP Versions.

Also see https://www.virtualmin.com/node/53226

Are you not able to select 5.4 via Virtualmin | Server Configuration | PHP Versions?

I selected 5.4, but it seemed to ignore it and went to 7.3.

Note that when you select a version of PHP via Virtualmin | Server Configuration | PHP Versions, it applies to the directory (and subdirectories under that directory) that you specify for that version of PHP.

I suspect you are confusing this with the default CLI version of PHP that your server has been configured to run. See https://virtualmin.com/comment/809892#comment-809892 for one way to change this default.

Thank you for trying to help me, however, please note that I am not really clear on a lot of this. For instance, what does CLI version of PHP mean?
I just need the website on these servers to use PHP 5.4.

Ok, let’s try again. You have stated that after you changed PHP script execution mode from FPM to FCGId, you were able to select 5.4 as the version of PHP for your virtual servers. You also reported that your action of specifying 5.4 is being ‘ignored’.

Can you tell us how you know this? How exactly are you testing for the version of PHP which is being run for the virtual server?

I am running a file with the phpinfo() function in it. I run it on the individual virtual servers to tell what version it is using.

Also of note is there is no directory specified on the PHP Versions page. It is blank.

I see this on Virtualmin | Server Configuration | PHP Versions:


Is your screen any different from this?

Yes, the Default HTML directory is missing on my page.

That’s strange. I don’t know how that could happen.

What does it mean anyway? And is there a way to make it reappear?

I haven’t the foggiest, sorry.

Well sir, you have been very patient with me, and I thank you very much. Maybe someone will see this and have the answer. It’s past my bedtime anyway, so I will leave it at that. Thanks again.

Virtualmin CP -> System Settings -> Re-Check Comnfiguration .
Run that and tell us which PHP versions are getting detected and which one you said you installed.

The following PHP versions are available : 5.4.45 (/bin/php54-cgi), 7.0.27 (/opt/rh/rh-php70/root/usr/bin/php-cgi), 7.1.33 (/bin/php-cgi), 7.3.14 (/bin/php73-cgi), 7.1 (mod_php)

The following PHP-FPM versions are available on this system : 7.1.33 (php-fpm) 5.4.45 (php54-php-fpm) 7.0.27 (rh-php70-php-fpm)

These match up with what we installed.

Well, further investigation confirms that I cannot change the PHP version because “Default HTML directory” does not show up on the PHP Versions page. There is another server where that does show up, and I am able to switch versions freely. Now the question becomes, how do I make that show up?

Got it. When these virtual servers were added, we had a problem where only the home page showed up. Any links produced an nginx error. We solved it by changing the location line in the nginx config file and adding the following: fastcgi_split_path_info ^(.+.php)(/.+)$; Now I have no idea what it does, nor why it works, but it does. What it also does is prevent the server from using FCGI, so changing PHP versions, is impossible. Unless…

Thankfully, when I changed the nginx conf file, I commented out the old lines instead of deleting them. I switched them back temporarily, made the change to PHP 5.4, and switched back.

All is well now. Thanks to all who tried to help.

1 Like