yum 安装 php55-php-cli 后找不到 php 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27982024/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php command not found after yum install php55-php-cli
提问by Oliver Bayes-Shelton
So I am using the EPEL repo with yum, When I run the command everything installs fine:
所以我将 EPEL 存储库与 yum 一起使用,当我运行命令时,一切安装正常:
sudo yum install php55-php-cli
However when I run:
但是,当我运行时:
php
I get the error:
我收到错误:
php command not found
Does anyone know why ?
有谁知道为什么?
update
更新
People are throwing around different packages to install which is wrong, when I do yum search php5 | grep 'cli'
the results are:
人们扔不同的包来安装哪个是错误的,当我这样做时yum search php5 | grep 'cli'
,结果是:
php54-php-cli.x86_64 : Command-line interface for PHP
php54-php-pecl-ircclient.x86_64 : IRC Client
php54-php-pecl-radius.x86_64 : Radius client library
php54-php-pecl-stomp.x86_64 : Stomp client extension
php54-php-pecl-yaz.x86_64 : Z39.50/SRU client
php55-php-cli.x86_64 : Command-line interface for PHP
php55-php-pecl-ircclient.x86_64 : IRC Client
php55-php-pecl-radius.x86_64 : Radius client library
php55-php-pecl-stomp.x86_64 : Stomp client extension
php55-php-pecl-yaz.x86_64 : Z39.50/SRU client
php56-php-cli.x86_64 : Command-line interface for PHP
php56-php-pecl-ircclient.x86_64 : IRC Client
php56-php-pecl-radius.x86_64 : Radius client library
php56-php-pecl-stomp.x86_64 : Stomp client extension
php56-php-pecl-yaz.x86_64 : Z39.50/SRU client
回答by Oliver Bayes-Shelton
Hey all and future me (I will of forgotten this next year),
嘿,未来的我(明年我会忘记这个),
To fix this issue I did two things.
为了解决这个问题,我做了两件事。
yum install php55
source /opt/remi/php55/enable
yum install php55
source /opt/remi/php55/enable
to test running php -v now works
测试运行 php -v now works
update
更新
if you are using puppet you cannot run the command source
so I found another solution
如果您使用的是 puppet,则无法运行该命令,source
因此我找到了另一个解决方案
When you run the command ls -la
you can see that php will run but if you do php56 -v
so my second option would be to symlink php to /opt/remi/php56/root/usr/bin/php
当您运行该命令时,ls -la
您可以看到 php 将运行,但如果您这样做php56 -v
,我的第二个选择是将 php 符号链接到/opt/remi/php56/root/usr/bin/php
[vagrant@localhost ~]$ ls -la /usr/bin/ | grep 'php'
lrwxrwxrwx 1 root root 32 Jan 28 16:57 php56 -> /opt/remi/php56/root/usr/bin/php
lrwxrwxrwx 1 root root 36 Jan 28 16:57 php56-cgi -> /opt/remi/php56/root/usr/bin/php-cgi
lrwxrwxrwx 1 root root 33 Jan 28 16:57 php56-pear -> /opt/remi/php56/root/usr/bin/pear
lrwxrwxrwx 1 root root 38 Jan 28 16:57 php56-phar -> /opt/remi/php56/root/usr/bin/phar.phar
回答by Mircea Stanciu
I ran this in a docker (after installing remi in centos7):
我在 docker 中运行了这个(在 centos7 中安装了 remi 之后):
yum -y --enablerepo remi,remi-php55 install php.x86_64 php-pecl-apcu.x86_64 php-pecl-memcached.x86_64 php-pecl-xdebug.x86_64
php -v returns PHP 5.5.34 (cli)
php -v 返回 PHP 5.5.34 (cli)
php -m shows correct modules
php -m 显示正确的模块
php --ini indicates all ini files in /etc/php.d are correctly installed
php --ini 表示 /etc/php.d 中的所有 ini 文件都已正确安装