Score:2

Any other ways to make multiple sites on one server use different PHP versions?

np flag

I recently upgraded the PHP version on 3 production servers to 7.4, along with MySQL and Apache2. Today we learned that one of the websites is still showing 7.2 in phpinfo(), despite php -v showing 7.4 at the CLI. I checked the .conf file for the site (/etc/apache2/sites-available/site1.your_domain.conf), but it doesn't show what I expected it to, namely it doesn't mention a PHP version at all. I figured there'd be something like this example:

<FilesMatch \.php$>
      SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
</FilesMatch>

But no, the <FilesMatch> section of the .conf file for my site says this:

<FilesMatch "\.(cgi|shtml|phtml|php)$">
               SSLOptions +StdEnvVars
</FilesMatch>

There's no mention of the PHP version anywhere in the site .conf file. I was under the impression that if SetHandler wasn't set that the site would default to the webserver default (7.4). So what is keeping it at 7.2?

I'm kind of at a loss as to where to look now. My Google-fu is failing me. Every search I try simply tells me how to change the CLI version of PHP or set the above settings in the VirtualHost section of the individual site config using SetHandler. Nothing that seems to apply to my situation unless I'm missing something. Any ideas? Thanks ahead of time.

pa4080 avatar
cn flag
What is the third line (Server API) of `<?php phpinfo(); ?>`? I suppose it is *Apache 2.0 Handler* which means the Apache web server uses PHP module instead of *FPM/FastCGI* service to handling the PHP files. In that case you need to `sudo a2dismod php7.2`, then `sudo a2enmod php7.4` and finally `sudo systemctl restart apache2.service`. Otherwise you must setup Apache2 to work with FPM and change the `VH.conf` file.
pa4080 avatar
cn flag
If the module is not installed: `sudo apt install libapache2-mod-php7.4`.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.