CentOS7.7にphp -vで「No such file or directory」の解決方法

2020年6月24日

1.エラー現象
# php -v
-bash: /usr/bin/php: No such file or directory
# which php
/usr/bin/which: no php in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)

2.phpのインストールディレクトリを確認する
# which php
/opt/remi/php74/root/usr/bin/php
/opt/remi/php74/root/usr/include/php
/opt/remi/php74/root/usr/lib64/php
/opt/remi/php74/root/usr/share/php

3.環境変数を設定する
# export PATH=$PATH:/opt/remi/php74/root/usr/bin/
# source /etc/profile

4.PHPバージョン再度確認
# php -v
PHP 7.4.7 (cli) (built: Jun 9 2020 10:57:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.7, Copyright (c), by Zend Technologies
with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

CentOS

Posted by arkgame