-bash:php:找不到命令-Centos6.7 [英] -bash: php: command not found - Centos6.7

查看:84
本文介绍了-bash:php:找不到命令-Centos6.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上安装了两个版本的PHP:

I have two versions of PHP installed on the server:

$ find / -name php -type f

结果:

/opt/rh/php54/root/usr/bin/php
/opt/rh/php55/root/usr/bin/php

我已将php54路径添加到〜/ .bash_profile

I've added php54 path to ~/.bash_profile

$ echo $PATH

结果:

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/opt/rh/php54/root/usr/bin/php

但是 $ php -v 仍然不起作用。

实际上,如果我 $ cd / opt / rh / php54 / root / usr / bin 并从目录本身运行 php -v ,它仍然不会工作。我得到:

in fact if I $ cd /opt/rh/php54/root/usr/bin and run php -v from the directory itself, it still doesn't work. I get:

-bash: php: command not found

已安装PHP,因为有网站在运行,只是命令行无法正常工作...

PHP is installed as there are websites running, just command line is not working...

两者

php55-php-cli-5.5.21-4.el6.x86_64
php54-php-cli-5.4.40-2.el6.x86_64

已安装...

推荐答案

错误的路径:

查找结果:

/opt/rh/php54/root/usr/bin/php
                           ^^^--- your php binary

$ PATH仅期望 DIRECTORIES 。您在$ PATH中列出了上述路径,这意味着Shell将搜索 ... / usr / bin / php / php 。请注意加倍的 php 。第一个是您在$ PATH中添加的目录,第二个是您尝试运行的程序。 $ PATH条目应为 ... / usr / bin / ,而没有 php

$PATH expects only DIRECTORIES. You listed the above path in $PATH, which means that the shell will be searching for .../usr/bin/php/php. Note the doubled php. First one is the "directory" that you added in $PATH, while the second one is the program you're trying to run. The $PATH entry should be JUST .../usr/bin/, WITHOUT the php.

这篇关于-bash:php:找不到命令-Centos6.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆