作为程序员一定要保持良好的睡眠,才能好编程

-bash: php: command not found 解决方法

发布时间:2020-03-03



php -r "readfile('http://install.phpcomposer.com/installer');" | php

-bash: php: command not found



[root@VM_11_128_centos src]# which php

/usr/bin/which: no php in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)


先找到php安装的路径


[root@VM_11_128_centos src]# cd /usr/local/php

[root@VM_11_128_centos php]# ls

bin  etc  include  lib  php  sbin  var

[root@VM_11_128_centos php]# cd bin/

[root@VM_11_128_centos bin]# ls

phar  phar.phar  php  php-cgi  php-config  phpdbg  phpize

[root@VM_11_128_centos bin]# pwd

/usr/local/php/bin


建立软连接 到  /usr/sbin/ 目录下

[root@VM_11_128_centos bin]# ln -s /usr/local/php/bin/php /usr/sbin/php

[root@VM_11_128_centos bin]# php -v

PHP 7.0.10 (cli) (built: Oct 31 2016 16:19:52) ( NTS )

Copyright (c) 1997-2016 The PHP Group

Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

    with Zend OPcache v7.0.10, Copyright (c) 1999-2016, by Zend Technologies