After changing PHP to 8.1 for a domain it still shows as 8.0

Operating System & Version
CentOS v7.9.2009
cPanel & WHM Version
108.0.15

Flyer

Active Member
Jun 15, 2007
34
3
58
The server has PHP 8.0 and 8.1 installed, but using MultiPHP Manager to set the PHP version to 8.1 does not seem to work. Subsequently running php --version in a shell for that domain gives "8.0.28".

From the WHM terminal I get "8.1.17".

The domain needs 8.1 for a Laravel 10 app, so how can I fix this?
 

DennisMidjord

Well-Known Member
Sep 27, 2016
361
80
78
Denmark
cPanel Access Level
Root Administrator
Running php --version using CLI will always use the version of PHP that's defined as default. What you could do is create a file called "info.php" with the following contents in the website directory:
```
<?php
phpinfo();
```
When you access "info.php" in your browser, it will show you what version of PHP the website is running.
After changing the PHP version for the website, try to open the website's .htaccess. At the bottom, there should be a line that defines PHP 8.1 as the version.
 

Flyer

Active Member
Jun 15, 2007
34
3
58
Thanks for your helpful response. I changed the default to 8.1, as I had to run composer update from a CLI, and that solved the problem. The website was already running 8.1, as you said.
 
  • Like
Reactions: cPRex

DennisMidjord

Well-Known Member
Sep 27, 2016
361
80
78
Denmark
cPanel Access Level
Root Administrator
If you're trying to run a specific PHP version from CLI, you could just use the full path to the PHP executable:
  • /usr/local/bin/ea-php81
  • /usr/local/bin/ea-php80
  • /usr/local/bin/ea-php74
  • ...
  • ...
 
  • Like
Reactions: cPRex

Flyer

Active Member
Jun 15, 2007
34
3
58
Thanks for the tip.

It would be less confusing if cPanel changed this comment on the WHM/MultiPHP Manager page:

This setting applies to new account creations and domains set to inherit the System PHP Version.

to something like this:

This setting applies to new account creations and domains set to inherit the System PHP Version, and to all CLI shells.