PHP Cli not running after migrate to EasyApache 4

Trendafilov

Member
Mar 11, 2017
8
0
1
Plovdiv
cPanel Access Level
Root Administrator
Hello,
I running VPS Server on GoDaddy.
After migrate to EasyApache 4 due to requirments for Magento 2.1 php commands are not acceptable.

php bin/magento saying:
Code:
php bin/magento cache:flush
Content-type: text/html; charset=UTF-8

bin/magento must be run as a CLI application[[email protected] www.xxx-xxx.com]#
If i try to do php-cli as an other server works php-cli instead of php only its saying :
Code:
php-cli bin/magento cashe:flush

bash: php-cli: command not found
So im struggling find how to fix the issue.

Server is new just started. Installed EasyApache 4 and update WHM to last version 62.0..
Code:
PHP Version is: 7.0.16

[[email protected] www.xxx-xxx.com]# php -v
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 7.0.16 (cgi-fcgi) (built: Feb 22 2017 20:52:04)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.16, Copyright (c) 1999-2017, by Zend Technologies
[[email protected] www.xxx-xxx.com]#
Any suggestions?

All help will be very appreciated!
 
Last edited by a moderator:

Trendafilov

Member
Mar 11, 2017
8
0
1
Plovdiv
cPanel Access Level
Root Administrator
php70-cli is installed as well..
Code:
[[email protected] www.xxx-xxx.com]# yum search php70-php-cli
Loaded plugins: fastestmirror, tsflags, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 104.219.172.10
 * base: mirror.lax.hugeserver.com
 * extras: mirrors.usc.edu
 * updates: centos.mirrors.hoobly.com
===================================== N/S Matched: php70-php-cli =====================================
ea-php70-php-cli.x86_64 : Command-line interface for PHP
Name and summary matches only, use "search all" for everything.
Code:
[[email protected] www.xxx-xxx.com]# yum install ea-php70-php-cli.x86_64
Loaded plugins: fastestmirror, tsflags, universal-hooks
Setting up Install Process
Loading mirror speeds from cached hostfile
 * EA4: 104.219.172.10
 * base: mirror.lax.hugeserver.com
 * extras: mirrors.usc.edu
 * updates: centos.mirrors.hoobly.com
Package ea-php70-php-cli-7.0.16-1.1.2.cpanel.x86_64 already installed and latest version
Nothing to do
[[email protected] www.xxx-xxx.com]#
 
Last edited by a moderator:

Trendafilov

Member
Mar 11, 2017
8
0
1
Plovdiv
cPanel Access Level
Root Administrator
Problem SOLVED:

was need to do :
Code:
[[email protected] ea-php70]# yum install ea-php70
Loaded plugins: fastestmirror, tsflags, universal-hooks
Setting up Install Process
Loading mirror speeds from cached hostfile
 * EA4: 104.219.172.10
 * base: mirror.lax.hugeserver.com
 * extras: mirrors.usc.edu
 * updates: centos.mirrors.hoobly.com
Package ea-php70-7.0.16-1.1.1.cpanel.x86_64 already installed and latest version
Nothing to do
[[email protected] ea-php70]# source /opt/cpanel/ea-php70/enable
[[email protected] ea-php70]# cd /home/xxx/public_html/www.xxx-xxx.com/
[[email protected] www.xxx-xxx.com]# php bin/magento cache:flush
Flushed cache types:
config
layout
block_html
collections
reflection
db_ddl
eav
config_integration
config_integration_api
full_page
translate
config_webservice
[[email protected] www.xxx-xxx.com]#
Maybe someone esle will have this issue and would be usefull.
 
Last edited by a moderator:

Trendafilov

Member
Mar 11, 2017
8
0
1
Plovdiv
cPanel Access Level
Root Administrator
Hello Michael,
Thanks fot the info, i read it, but its written only difference between cgi and cli.

Please tell me how to switch from php70 (cgi-fcgi) to php70 (cli) permanent to run the commands over SSH.
 

Trendafilov

Member
Mar 11, 2017
8
0
1
Plovdiv
cPanel Access Level
Root Administrator
My other VPS @ Godaddy was okay to use the php instead of full path. Right now command execute with php-cli.

So there is some way to make this happen.
When i check version with php -v

if appear PHP 7.0.16 (cli) instead of PHP 7.0.16 (cgi-fcgi) , php execute is correct.


Is anyone familiar how to change it for ssh?

P.S: when execude this: source /opt/cpanel/ea-php70/enable , php has been changed temporary to PHP 7.0.16 (cli), php command executing fine till next login.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
My other VPS @ Godaddy was okay to use the php instead of full path. Right now command execute with php-cli.
It's likely that server used a different version of cPanel, or did not utilize EasyApache 4.

So there is some way to make this happen.
When i check version with php -v
You may find this third-party URL helpful:

EasyApache 4 & CLI based PHP utilities – Liquid Web Knowledge Base

If you need to make it work in every SSH session, then you could add the command to the bash profile:

How to Set and Unset Local, User and System Wide Environment Variables in Linux

Thank you.
 

tipofloe

Registered
Apr 16, 2017
4
1
3
Los Angeles
cPanel Access Level
Root Administrator
My other VPS @ Godaddy was okay to use the php instead of full path. Right now command execute with php-cli.

So there is some way to make this happen.
When i check version with php -v

if appear PHP 7.0.16 (cli) instead of PHP 7.0.16 (cgi-fcgi) , php execute is correct.


Is anyone familiar how to change it for ssh?

P.S: when execude this: source /opt/cpanel/ea-php70/enable , php has been changed temporary to PHP 7.0.16 (cli), php command executing fine till next login.

Problem Solved Temporary.

Every time i exit, problem exist again.
Someone give me a suggestion how to make permanent source /opt/cpanel/ea-php70/enable?
Hello,

I've searched the internet over 14 hours to find your post. I am also on GoDaddy and I also have their VPS service and EasyApache4. My problem, however started to surface today when I was following instructions to install the latest version of git for CentOS and followed these commands:

cd git-2.0.1
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

Anyway, I can't thank you enough for find out that using source /opt/cpanel/ea-php70/enable command changes the php to CLI mode but I am having trouble making this permanent. I've read the article link provided by cPanelMichael, but I am having difficulties understanding it and thus am not able to make this solution permanent.

I've tried:
echo "export PATH=$PATH:/opt/cpanel/ea-php70/root/usr/bin:/opt/cpanel/ea-php70/root/usr/sbin${PATH:+:${PATH}} >> /etc/bashrc

and

echo "export PATH=$PATH:/opt/cpanel/ea-php70/root/usr/bin:/opt/cpanel/ea-php70/root/usr/sbin${PATH:+:${PATH}} >> /etc/bashrc

and then source /etc/bashrc

but when I sign out and sign back in, I have to run source /opt/cpanel/ea-php70/enable again.

What did you end up doing to make this permanent?

Thank you for your help.
 

tipofloe

Registered
Apr 16, 2017
4
1
3
Los Angeles
cPanel Access Level
Root Administrator
I got it to work!

I ended up adding editing the bashrc file as the way I was entering it duplicated existing export PATH settings. I edited all the duplicates out and the end result was:

export PATH=/opt/cpanel/ea-php70/root/usr/bin:/opt/cpanel/ea-php70/root/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/usr/local/git/bin
export MANPATH=/opt/cpanel/ea-php70/root/usr/share/man:

It worked out beautifully! All thanks to you and to Michael! I actually understood his article. :D
 

tipofloe

Registered
Apr 16, 2017
4
1
3
Los Angeles
cPanel Access Level
Root Administrator
I got it to work!

I ended up adding editing the bashrc file as the way I was entering it duplicated existing export PATH settings. I edited all the duplicates out and the end result was:

export PATH=/opt/cpanel/ea-php70/root/usr/bin:/opt/cpanel/ea-php70/root/usr/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/usr/local/git/bin
export MANPATH=/opt/cpanel/ea-php70/root/usr/share/man:

It worked out beautifully! All thanks to you and to Michael! I actually understood his article. :D

Apparently this was not the final piece of the puzzle. After I've saved the bashrc file, sudo, vi, yum commands did not work. I I went ahead and restored the order back to the way it was but now cgi-fcgi is showing when I type php -v.

Help Please?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463
I can't believe it was as simple as just adding your command to the /etc/bashrc file!! Now everything works well!!
Hello @tipofloe,

Could you post the updated steps/commands you used to ensure the changes were preserved?

Thanks!