user9048585
user9048585

Reputation:

CentOS installed php72 but command line php isn not working

I'm reading the following tutorial on installing PHP 7.2 on CentOS 7 https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/

It basically says;

sudo yum install epel-release
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72
sudo yum update
sudo yum install php72

Then it says to verify the installation using the standard

php --version

Which returns the following;

-bash: php: command not found

BUT, if i type the following;

php72 --version

It works just fine and returns the version.

The problem is that everything relies on the command php and not php72

Any idea on what i should be doing?

Upvotes: 20

Views: 56879

Answers (6)

farshid kashefi
farshid kashefi

Reputation: 21

You have to install php72-php. This adds php binary, httpd config and php.ini files

for solve "php -v" you should install php-cli

yum install php72-php php-cli

Upvotes: 2

varun sharma
varun sharma

Reputation: 1057

The steps which worked for me are

It removes old php and installs php72

I followed the same article and stuck on the same issue.

sudo yum -y remove php*

sudo yum install epel-release

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

sudo yum install mod_php72w php72w-opcache php72w-pdo php72w-mysql php72w-mbstring

sudo scl enable php72 bash

sudo yum update


The instructions which worked for me are from the given link. PHP 7.2 on CentOS/RHEL 7.4 via Yum

Upvotes: 6

Yaser Selim
Yaser Selim

Reputation: 21

yum install php72w-cli , CLI is the command line interface so you need to install it, check for compatible version.

Upvotes: 1

Remi Collet
Remi Collet

Reputation: 7031

Please read the Wizard instructions

If you need a single version, using remi-php72 repository, and the php-* packages, the command will be php.

# yum-config-manager --enable remi-php72
# yum update
# yum install php-cli
# php -v

If you need multiples versions, the php72-php-* packages are available, and the command is php72 or

# yum install php72-php-cli
# php72 -v
# scl enable php72 bash
# php -v

So, according to your question, you have enable the remi-php72 repository, but installed the php72* packages from the remi-safe repository...

Upvotes: 58

ewcz
ewcz

Reputation: 13087

I think it would be better to rely on a "standard" solution such as, e.g., the alternatives system. To this end, you might do:

sudo alternatives --install /usr/local/bin/php php /usr/bin/php72 1

This will create a symlink in /usr/local/bin which is wired via the alternatives system to /usr/bin/php72. This has the advantage that in case you would install several php versions, the alternatives command allows you to switch among them easily...

Upvotes: 2

Radek Suski
Radek Suski

Reputation: 1392

I am not sure what is the cause but this is what you can do

whereis php72

It will give the path. Something like:

php: /usr/bin/php72

Then you can do:

ln -s /usr/bin/php72 /usr/bin/php

Upvotes: 23

Related Questions