Skip to main content

Command line /usr/local/bin/php and PHP-FPM

Comments

9 comments

  • ItsMattSon
    I've learned that the php-cli interpreter is /usr/local/bin/ea-php70 and the memory_limit is 128M because that is what is set in WHM's MultiPHP INI Editor. Same for disable_functions, if I remove exec my test script works. Is there a way to override this for php-cli per account so that these can remain as default for new accounts?
    0
  • cPanelMichael
    Is there a way to override this for php-cli per account so that these can remain as default for new accounts?

    Hi Matt, You should be able to use the "/usr/bin/php" path for the EA4 php-cli package. It should find the version specified for the directory you are currently in (not the directory the file exists in). If you do not run the command from the document root for the domain (e.g. /home/username/public_html/), it will use the system default version. Thank you.
    0
  • ItsMattSon
    Hi @cPanelMichael, Looks like the documentation doesn't agree with itself? Looks like /usr/bin/php is the cgi binary and /usr/local/bin/php is the cli binary? EasyApache 4 and the ea-php-cli Package - EasyApache 4 - cPanel Documentation What does the ea-php-cli package do? The ea-php-cli package installs the following PHP binaries:
    • /usr/bin/php " This executable uses the php-cli binary for the specified PHP version.
    • /usr/local/bin/php " This executable uses the php-cgi binary for the specified PHP version.
    What is the difference between /usr/bin/php and /usr/local/bin/php? The /usr/bin/php binary calls the PHP CGI handler. The /usr/local/bin/php binary calls the PHP command-line handler. My php -v for each is: [me@srv ~]$ /usr/bin/php -v ea-php-cli Copyright 2017 cPanel, Inc. PHP 7.0.27 (cgi-fcgi) (built: Feb 7 2018 02:54:05) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies [me@srv ~]$ /usr/local/bin/php -v ea-php-cli Copyright 2017 cPanel, Inc. PHP 7.0.27 (cli) (built: Feb 7 2018 02:53:45) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies With that said, I changed my MultiPHP INI Editor memory limit to 512M (in domain's cPanel) but it still says 128M as per the value set in MultiPHP INI Editor via WHM. I definitely changed directory to /home/user/public_html before running php -r "echo ini_get('memory_limit');" Any ideas?
    0
  • cPanelMichael
    Hi Matt, Here's an example of the steps I took in an effort to reproduce this: 1. Browsed to /home/username/public_html via SSH and checked the PHP memory_limit: # cd /home/username/public_html/ # /usr/bin/php -i|grep memory_limit memory_limit 128M 128M
    2. Browsed to cPanel >> MultiPHP INI Editor for this account, selected the primary domain name and changed the memory limit PHP value to 65M. 3. Repeated step 1, and noticed the updated value: # /usr/bin/php -i|grep memory_limit memory_limit 65M 65M
    4. Enabled PHP-FPM for the account, repeated steps 1-3 above (except using 70M as the value), and confirmed it was properly reflected: ]# /usr/bin/php -i|grep memory_limit memory_limit 70M 70M
    Can you verify which steps you are using to reproduce the issue, and which version of cPanel is installed on your system? Thanks!
    0
  • ItsMattSon
    Hi Michael, Your test returns the same results for me, same observations, but sorry to cut that short I think I need to start over to explain what's going on here at least for me. /usr/bin/php (cgi-fcgi) honours the current/working directory ini file (/home/user/public_html/php.ini) IF it exists, which it does if you Save your cPanel MultiPHP INI Editor settings. I know this by checking the Loaded Configuration File line with the below command similar to yours. That line shows /home/user/public_html/php.ini if it exists otherwise if shows /opt/cpanel/ea-php70/root/etc/php.ini which hosts the WHM MultiPHP INI Editor settings. So /usr/bin/php appears to load the local values - cool. /usr/bin/php -i | grep "Loaded Configuration" Loaded Configuration File /home/user/public_html/php.ini
    However, the same cannot be said for /usr/local/bin/php... /usr/local/bin/php (cli) does not honour the /home/public_html/php.ini at all, even if it exists. It always loads /opt/cpanel/ea-php70/root/etc/php.ini whether you're in the public_html directory or not. Perhaps this is by design but this really makes it hard to run Magento 2 commands from the command line, as it's pulling the WHM memory_limit (128M) from /opt/cpanel/ea-php70/root/etc/php.ini instead of using the 2G limit I set in /home/user/public_html/php.ini via cPanel MultiPHP INI Editor. Magento's upgrade needs min 768M but recommended 2G (crazy, i know). I can pass the directives to the binary directly with the -d switch which is a work-around but it is not preferable... (ie. /usr/local/bin/php -d memory_limit=2G /home/user/public_html/bin/magento setup:upgrade). Is it possible to have the CLI binary honour the account's INIs?
    0
  • cPanelMichael
    However, the same cannot be said for /usr/local/bin/php... /usr/local/bin/php (cli) does not honour the /home/public_html/php.ini at all, even if it exists. It always loads /opt/cpanel/ea-php70/root/etc/php.ini whether you're in the public_html directory or not. Perhaps this is by design but this really makes it hard to run Magento 2 commands from the command line, as it's pulling the WHM memory_limit (128M) from /opt/cpanel/ea-php70/root/etc/php.ini instead of using the 2G limit I set in /home/user/public_html/php.ini via cPanel MultiPHP INI Editor. Magento's upgrade needs min 768M but recommended 2G (crazy, i know). I can pass the directives to the binary directly with the -d switch which is a work-around but it is not preferable... (ie. /usr/local/bin/php -d memory_limit=2G /home/user/public_html/bin/magento setup:upgrade). Is it possible to have the CLI binary honour the account's INIs?

    Hi Matt, It looks like you've encountered an issue we have an internal case open to address. Internal case CPANEL-17535 is open to improve our implementation of PHP-CLI so that it properly detects the use of PHP-FPM. Additionally, while not entirely related to the issue you are currently facing, another open case to be aware of is CPANEL-15923. Here's a brief summary of this case: [QUOTE] When a customer uses PHP-FPM, the "AddType" directive is commented out from the domain's DocRoot's .htaccess file. This causes the "ea-php-cli" binary (/usr/bin/php & /usr/local/bin/php) to be unable to detect the PHP version set for that domain via MultiPHP Manager. This means that cron jobs and shell executed PHP using ea-php-cli will often run the incorrect version of PHP for the domain.
    Update: Internal case CPANEL-23538 will address the issue reported as part of CPANEL-17535. Thank you.
    0
  • SoftDux
    I am sitting with the same problem. Both WHM and cPanel is set to use PHP 7.2, but in shell I still get PHP 7.0: php -v ea-php-cli Copyright 2017 cPanel, Inc. PHP 7.0.33 (cli) (built: Feb 10 2019 12:54:41) ( NTS )
    ea-php70 -v PHP 7.0.33 (cli) (built: Feb 10 2019 17:39:23) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    ea-php71 -v PHP 7.1.26 (cli) (built: Feb 10 2019 17:54:56) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    How do I get shell to use PHP 7.2? ea-php72 -v PHP 7.0.33 (cli) (built: Feb 10 2019 12:54:41) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    0
  • cPanelMichael
    Hello @SoftDux, We provide an overview of how the PHP-CLI package works at: EasyApache 4 and the ea-php-cli Package - EasyApache 4 - cPanel Documentation Can you verify which directory you are running that command from, and if you are logged in as "root"? Also, which cPanel & WHM version is installed on the system? Thank you.
    0
  • Floyd John
    I agree with ItsMattSon, I think the documentation is wrong. I've already spent some time trying to understand. The documentation says /usr/local/bin/php will use CLI, ie in theory max_execution_time would be set to 0. But look what happens: WHM has max_execution_time 30s by default and php.ini from an "anyaccount" account contains local settings with max_execution_time 600s. When I run a cpanel cron task using /usr/local/bin/php I get "Fatal error: Maximum execution time of 30 seconds exceeded in". That is, /usr/local/bin/php cannot be using CLI. Please, any ideas on this?
    0

Please sign in to leave a comment.