composer using wrong php package

SolsWebdesign

Registered
Feb 1, 2017
3
0
1
Netherlands
cPanel Access Level
Reseller Owner
Hi,

I'm running cPanel 62.0.16, WHM 62.0 (build 16) and am developing magento 2 stores. Composer is installed in /opt/cpanel/ and when navigating to that directory I see

.. composer ea-apr15 ea-php54 ea-php55 ea-php56 ea-php70 libmcrypt perl5
so my php70 package is there.

In my magento 2 directory my magento 2 store uses the ea-php70 just fine. But when I want to use composer I find that composer seems to use ea-php54 (the cPanel default???) and I cannot tell it to use the ea-php70 that I have installed for my magento 2 store.

I get errors like allow_url_fopen must be enabled (indeed it is enabled for my ea-php70 package and is not enabled for my ea-php54 package) and allowed memory exceeded (my ea-php54 package only has a memory_limit of 32 but I don't use it anyway)

How can I tell composer to use the ea-php70 package that I specifically made for my magento 2 stores? And why on earth is it using that php54 package??? I can't even run composer self-update because of the php54...

I have looked everywhere and WHM is great but somehow Composer in cPanel keeps falling back on a package and PHP version that I do not want it to use.

Can anybody tell me why and how to change that?

Thank you very much in advance :)
regards,
Isolde
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello,

Could you upload a PHPINFO file to the document root you are using Composer in and verify which php.ini file is loaded?

Thank you.
 

SolsWebdesign

Registered
Feb 1, 2017
3
0
1
Netherlands
cPanel Access Level
Reseller Owner
Hi,

In the document root where I use composer I have uploaded a phpinfo.php and the php.ini path reads:
/opt/cpanel/ea-php70/root/etc
also, it says at the top PHP Version 7.0.16 as expected. Also it says:
memory_limit 768M (local value) 128M (master value)
which is correct and as expected.
However, composer gets stuck at 128M (the master value) and uses the master php 5.6.30 (cli) which seems to be used by cPanel
php -v shows me :
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 5.6.30 (cli) (built: Feb 22 2017 20:54:02)
and php -r "echo ini_get('memory_limit').PHP_EOL;" shows me :
128M
Because I'm developing Magento 2 stores I want my composer to use my ea-php70 package that I have made for this. However, no matter what I try (e.g. updating PATH), composer keeps using the wrong ea-php package and I can't seem to change that.
:-(
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello,

Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

Thank you.
 

SolsWebdesign

Registered
Feb 1, 2017
3
0
1
Netherlands
cPanel Access Level
Reseller Owner
Hello cPanelMichael,

In the end I moved my non-php7 projects to an older server and set cPanel to default to ea-php70 package. Setting cPanel to default to ea-php70 package and having my non-php7 projects set to ea-php56 did not work well. It is not my preferred solution but because of project pressure I have no choice. Even though it is now "solved" for me I decided to place a ticket anyway, I would like to see Composer use the right package (the one installed where I use Composer rather then the cPanel default php package) or I would like to learn how I can make Composer use the right package :)
Thank you for your help. My Support Request ID is: 8317099.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
My Support Request ID is: 8317099.
It looks like we've sent a reply to the ticket. Feel free to reply back to the ticket with any additional questions, and update this thread with the outcome if you can confirm the issue is addressed.

Thank you.
 

dbrookeJP

Active Member
Aug 24, 2016
28
1
3
Wisconsin
cPanel Access Level
Root Administrator
Hello, I had this exact same problem.
I've set an account to use PHP 7, and composer was failing due to it trying to use 5.6.32.

[snip]
php -v shows me :
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 5.6.30 (cli) (built: Feb 22 2017 20:54:02)
If you log into your <accountuser> and go to the magento store root, you should see your version:
su <accountuser>
cd /<path_to_your_magento_store_root>
php -v should report your user version of php (7.x).

Anyway, This is what I did.

Logged in as your <accountuser>.. ie.
su <youraccountuser>

Make an alias for composer to your specific PHP.. for me it was:
vi /home/<myuser>/.bashrc

Then add this below the "# User specific aliases and functions"
alias lcomposer='/opt/cpanel/ea-php70/root/usr/bin/php /opt/cpanel/composer/bin/composer'

Log out and in of your shell again... then you can use 'lcomposer' instead of 'composer'.

I also needed to edit the 'allow_url_fopen' php.ini value.
I tried to do this in cpanel's multiphp ini editor, but it did not work.. so I did it manually here:

/opt/cpanel/ea-php70/root/etc/php.ini

Not sure if that will stick.. but my lcomposer works now.

Hope that helps someone else.
Donovan
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Hello @dbrookeJP,

You can adjust the "System PHP Version" in "WHM >> MultiPHP Manager" if you want the default version of PHP configured on the system to be something other than PHP 5.6.

I also needed to edit the 'allow_url_fopen' php.ini value.
I tried to do this in cpanel's multiphp ini editor, but it did not work.. so I did it manually here:

/opt/cpanel/ea-php70/root/etc/php.ini

Not sure if that will stick.. but my lcomposer works now.
The "allow_url_fopen" PHP option falls under the "PHP_INI_SYSTEM" category and thus configuring it on a per-domain basis isn't allowed unless you use the suPHP handler. You can edit the value globally using the MultiPHP INI Editor option in Web Host Manager.

Thank you.
 

dbrookeJP

Active Member
Aug 24, 2016
28
1
3
Wisconsin
cPanel Access Level
Root Administrator
Hello @dbrookeJP,

You can adjust the "System PHP Version" in "WHM >> MultiPHP Manager" if you want the default version of PHP configured on the system to be something other than PHP 5.6.



The "allow_url_fopen" PHP option falls under the "PHP_INI_SYSTEM" category and thus configuring it on a per-domain basis isn't allowed unless you use the suPHP handler. You can edit the value globally using the MultiPHP INI Editor option in Web Host Manager.

Thank you.

Thanks Michael, there are cases where you want different versions of PHP.. so changing the default is not always a great option.. thus my solution.

Regarding allow_url_fopen, editing the directive globally in the MultiPHP INI Editor apparently doesn't mean it will work for the other PHP versions... as I tried that. I don't think I checked into suPHP, so that may be an option. That said, editing manually seemed to work. However, I will leave this thread saying that I do believe this could be made more easy in future releases by allowing that directive to be editable (somehow) per PHP version... just my opinion.

Thanks,
Donovan
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Regarding allow_url_fopen, editing the directive globally in the MultiPHP INI Editor apparently doesn't mean it will work for the other PHP versions
Hello,

That's correct. When editing the values globally using the MultiPHP INI Editor option in Web Host Manager, you'd need to do so separately for each PHP version listed under "Configure basic settings of a PHP version" or "Edit the INI settings of a PHP version".

Thank you.
 

dbrookeJP

Active Member
Aug 24, 2016
28
1
3
Wisconsin
cPanel Access Level
Root Administrator
Hello,

That's correct. When editing the values globally using the MultiPHP INI Editor option in Web Host Manager, you'd need to do so separately for each PHP version listed under "Configure basic settings of a PHP version" or "Edit the INI settings of a PHP version".

Thank you.
Thanks, neither of those worked for me. I even restarted the web server after edits. As noted in my solution, I had to find and edit the .ini file manually. Anyway, thanks for the responses.. I have a solution for now.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Thanks, neither of those worked for me. I even restarted the web server after edits. As noted in my solution, I had to find and edit the .ini file manually. Anyway, thanks for the responses.. I have a solution for now.
Hi,

Generally, you shouldn't have to manually edit the .ini file. I'm happy to help troubleshoot that for you if you'd like. What PHP handler are you using?

Thank you.
 

grayloon

Well-Known Member
Oct 31, 2007
117
4
68
Evansville, IN
cPanel Access Level
Root Administrator
Twitter
I was having a similar issue with WHM 74. My default PHP version is 5.6 (for now), and I needed to use 7.1 due to composer requirements on a specific site. I was able to resolve the issue by using the full paths to PHP/composer while running the commands:

Code:
/opt/cpanel/ea-php71/root/usr/bin/php /usr/local/bin/composer install
 
  • Like
Reactions: cPanelMichael