MultiPHP Manager set to 8.1.1, and "php -v" gives 8.1.1 in public_html folder, but 5.6.4 in root directory?

Kadence

Active Member
Nov 25, 2006
32
1
158
My web host recently upgraded my PHP 5.6 to 8.1, and installed MultiPHP Manager. For a domain, I used cPanel to set the PHP for the account to 8.1, and if I do "php -v" inside the public_html folder for the user, it says I have 8.1.1. But if I go to the root folder for the user, it says I have 5.6.4.

It doesn't seem to a problem if I create .php files inside public_html. Though I have a programmer who says he needs to place some files below the web server root, and he doesn't have access to 8.1 there.

Is this normal? For MultiPHP manager to give 8.1.1 in the public_html folder only, and inherit it for the user root folder. And is there anything I can do to get 8.1.1 in the root folder? I presume that if I modified the PHP level for the whole server to 8.1.1 via WHM, the user root folder would inherit the 8.1.1, but I don' t want to do that as it might break other sites that wouldn't be compatible with PHP 8.
 

kodeslogic

Well-Known Member
PartnerNOC
Apr 26, 2020
562
259
138
IN
cPanel Access Level
Root Administrator

Kadence

Active Member
Nov 25, 2006
32
1
158
You can refer to the official documentation to know how to set PHP version for a domain
Thank you. I did set the PHP version to 8.1.1 using cPanel and MultiPHP manager.

My issue is that I am getting different versions within the /public_html folder, and above the /public_html folder. If I type "php -v" from somewhere inside the /public_html directory, it says 8.1.1. If I go to the / folder, or to say /var or /public_ftp or /mail, "php -v" gives me 5.6.40.

Is this a known issue, or a bug with my installation?
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
856
367
363
cPanel Access Level
DataCenter Provider
If you are outside the home folder, you're going to get the system default. If you are in a sites home folder then you'll get whatever version of PHP that site is set to.
 
  • Like
Reactions: Kadence

andrew.n

Well-Known Member
Jun 9, 2020
965
358
63
EU
cPanel Access Level
Root Administrator
+ you can set different version for Home Directory and for the domain itself.
 

Kadence

Active Member
Nov 25, 2006
32
1
158
When attempting to install certain packages from github via composer, I am getting a PHP compatability error. My host thinks this is because of MultiPHP manager, but they don't provide support for it or know any solution.

I am getting this for all PHP 8 libraries from github that I tried, but I will use PHP Panther as an example.

I use the command, "composer req symfony/panther" as described in the readme. But I get the error:

[InvalidArgumentException]
Package symfony/panther has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version
According to the composer.json:

Here are the requirements:
"require": {
"php": ">=8.0",
"ext-dom": "*",
"ext-libxml": "*",
"php-webdriver/webdriver": "^1.8.2",
"symfony/browser-kit": "^5.3 || ^6.0",
"symfony/dependency-injection": "^5.3 || ^6.0",
"symfony/deprecation-contracts": "^2.4 || ^3",
"symfony/dom-crawler": "^5.3 || ^6.0",
"symfony/http-client": "^5.3 || ^6.0",
"symfony/http-kernel": "^5.3 || ^6.0",
"symfony/process": "^5.3 || ^6.0"
},
The PHP for my server is 5.6.4, but for the account/domain I am using composer with, in cPanel MultiPHP manager, I set the PHP to 8.1. I also tried setting it to 8.0. But composer still gives me these PHP version compatibility errors.

Is there anything I can do about this? Or is MultiPHP manager incompatible with composer? Would composer work if I set the PHP for the server to 5.6.4? I don't know if the issue is the inherited PHP version for the default server PHP version, or something else.
 

Kadence

Active Member
Nov 25, 2006
32
1
158
Hello! If you set up a PHP Info page for domains experiencing this PHP version concern, do you see the right version?
If I set up a page with phpinfo(); or "echo phpversion();", it shows 8.1.1. Since the .php is located within the /public_html folder.

But I am using MultiPHP, and the main server version is 5.6.4. Composer seems to interact with this version, I think. Even though I am calling composer from within the public_html folder.
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
856
367
363
cPanel Access Level
DataCenter Provider
Are you physically in the public_html folder or are you supplying the path to the public_html folder. You may also want to search for "run composer with a specific verison of PHP" or something similar. The wrong version of PHP may have been hardcoded in the composer config.
 
  • Like
Reactions: Kadence

Kadence

Active Member
Nov 25, 2006
32
1
158
Are you physically in the public_html folder or are you supplying the path to the public_html folder. You may also want to search for "run composer with a specific verison of PHP" or something similar. The wrong version of PHP may have been hardcoded in the composer config.
In Linux, I am in a sub-folder of the /public_html folder when I am calling the composer command. If I call "php -v" from this same location, it gives me 8.1.1.

I had kept the main server PHP version to 5.6.4, because I was worried about other sites breaking. But I edited all the other user accounts (other than the account I was talking about in this thread) from inheriting the PHP version, to actively being set to 5.6.4. Then I set the main server PHP version to 8.1.1. This seems to have solved the issue of composer giving a PHP compatibility error. The packages now install properly.

Though now I'm getting errors of the following variety, across different libraries:
"Fatal error: Uncaught Error: Class "Symfony\Component\BrowserKit\Client" not found in /home/compareng/public_html/goutte/vendor/fabpot/goutte/Goutte/Client.php:32 Stack trace: #0 {main} thrown in /home/compareng/public_html/goutte/vendor/fabpot/goutte/Goutte/Client.php on line 32"
-----
"Fatal error: Uncaught Error: Class "Symfony\Component\BrowserKit\AbstractBrowser" not found in /home/compareng/public_html/panther/vendor/symfony/panther/src/Client.php:55 Stack trace: #0 {main} thrown in /home/compareng/public_html/panther/vendor/symfony/panther/src/Client.php on line 55"
I think I'll have to try and find assistance from a composer expert on this. Thank you all for the assistance.
 

bouvrie

Active Member
Apr 6, 2012
38
6
58
cPanel Access Level
Root Administrator
+ you can set different version for Home Directory and for the domain itself.
Bumping this post, because I suspect to have the same issue, and there's some miscommunication in this topic. Just to be clear: I think it is NOT possible to set a different version for Home Directory.

It is true that MultiPHP INI Editor allows editing the PHP INI settings from:
  1. A user's home directory
  2. Each of the user's domains' document roots. Each distinct document root can have its own PHP version configured.
however, the MultiPHP MANAGER on the other hand can only set the PHP version to use for each of the the domains - it can NOT set the PHP version used by a user's home directory.

Unless I'm missing something here - is there a way to change the PHP version used by the user's home directory, without changing the global system PHP version? It does not make sense to have a user's domains set to php version A, while the user's shell and cron jobs run php version B...
 

andrew.n

Well-Known Member
Jun 9, 2020
965
358
63
EU
cPanel Access Level
Root Administrator
So if you have several domains and subdomains under the same cPanel account and you go to MultiPHP Manager then you will be able to set a different PHP version for each of them. See this screenshot as an example.
 
  • Like
Reactions: cPRex