找不到 PHP-CLI
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18112714/
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-CLI not found
提问by Dennis Strooband
After I tried for hours to find the good path for PHP-CLI, i finally found it. But my proud was soon gone again.
在我尝试了几个小时找到 PHP-CLI 的好路径之后,我终于找到了它。但我的骄傲很快又消失了。
Still i got the following error:
我仍然收到以下错误:
The following requirements were not met. As a result video uploads have been disabled.
未满足以下要求。因此,视频上传已被禁用。
- Unable to locate path to PHP-CLI
- 无法找到 PHP-CLI 的路径
I have tried much different paths
我尝试了很多不同的路径
- bin/php
- usr/local/lib
- usr/local/lib/php
- usr/local/bin/php (this is the good one I thought).
- 垃圾箱/ PHP
- 用户/本地/库
- usr/local/lib/php
- usr/local/bin/php(这是我认为的好)。
Still getting the same error as above. Whats happening? My server is not running in Safe Mode and my exec()
are enabled via the php.ini file.
仍然得到与上述相同的错误。发生了什么?我的服务器没有在安全模式下运行,我exec()
是通过 php.ini 文件启用的。
Please help me..
请帮我..
Edit:
编辑:
Paul
保罗
Q: Have you tried any "fully qualified paths", e.g. "/bin/php" (not just "bin/php")?
问:您是否尝试过任何“完全限定路径”,例如“/bin/php”(不仅仅是“bin/php”)?
A: I have tried both solutions, no result.
A:两种方案我都试过,都没有结果。
Q: Are you sure php-cli is installed on your system (it's typically a seperate package from the Apache PHP plug-in)? EXAMPLE: apt-get install php5-common libapache2-mod-php5 php5-cli.
问:你确定你的系统上安装了 php-cli(它通常是 Apache PHP 插件的独立包)?示例:apt-get install php5-common libapache2-mod-php5 php5-cli。
A: I tried this in the SSH of my server, its a CentOS server so he didn't found the comment
A:我在我的服务器的 SSH 中尝试过这个,它是一个 CentOS 服务器,所以他没有找到评论
@Peter:
@彼得:
If you installed PHP through your OS package manager, the path would probably be /usr/bin/php, which appears to be the only one you didn't try
如果您通过操作系统包管理器安装 PHP,则路径可能是 /usr/bin/php,这似乎是您没有尝试过的唯一路径
I tried that one now, i didn't help, still the same error:
我现在尝试了那个,我没有帮助,仍然是同样的错误:
Edit2
编辑2
@Dev-null
@Dev-null
You have found and what? Just knowing where >is located will not fix it, have you changed some >code or environment variable PATH to make it
你找到了什么?只知道 > 所在的位置不会修复它,您是否更改了一些 > 代码或环境变量 PATH 以使其成为
A: its an input field where i need to put the path in. I haven't changed any code, because PHP version 5.3.17 (CLI) installed on my CentOS server. So no need to change some code just for the path, right?
A:它是我需要输入路径的输入字段。我没有更改任何代码,因为我的 CentOS 服务器上安装了 PHP 版本 5.3.17 (CLI)。所以不需要只为路径更改一些代码,对吗?
Edit
编辑
My PHP info, PHP 5.3.17 (CLI) Check the image below..
我的 PHP 信息,PHP 5.3.17 (CLI) 检查下图..
Edit
编辑
When I do rpm -q php-cli
I get PHP-CLI not installed
and when I want to install i get No package php-cli available
. See image below.
当我做rpm -q php-cli
我得到的PHP-CLI not installed
,当我想安装我得到No package php-cli available
。见下图。
Edit
编辑
Result of /bin/php -v
below.
结果/bin/php -v
如下。
回答by álvaro González
CentOS ships the PHP command-line interpreter in the php-cli
package. So you first need to verify whether it's installed or not:
CentOS 在php-cli
软件包中提供了 PHP 命令行解释器。因此,您首先需要验证它是否已安装:
rpm -q php-cli
If installed, you can list all its files:
如果已安装,您可以列出其所有文件:
rpm -ql php-cli
... and filter out potential binaries:
...并过滤掉潜在的二进制文件:
rpm -ql php-cli | grep /bin/
You can get further details in the Using RPMchapter of the deployment guide.
您可以在部署指南的使用 RPM一章中获得更多详细信息。
If the package is not installed:
如果未安装软件包:
yum install php-cli
More info at Installing New Software with yum.
更多信息请参见使用 yum 安装新软件。
All this answer assumes that nobody broke the package system by installing software manually. If that happened, there's no way to tell what changes were made to the system.
所有这些答案都假设没有人通过手动安装软件来破坏软件包系统。如果发生这种情况,则无法判断对系统进行了哪些更改。
Edit #1:I've just seen your last edit where php-cli is up and running. Then, if you want to know the path you just need to type this:
编辑 #1:我刚刚看到了您在 php-cli 启动并运行的最后一次编辑。然后,如果你想知道路径,你只需要输入:
which php
Edit #2:You seem to have up to 4 binaries called php
in your path. I still think that the proper reliable way to find the php-cli
binary is running rpm -ql php-cli
but given that php
finds it on the path I'm pretty sure that it's located at /bin/php
and you can verify it by running:
编辑 #2:您php
的路径中似乎最多调用了 4 个二进制文件。我仍然认为找到php-cli
二进制文件的正确可靠方法正在运行,rpm -ql php-cli
但鉴于php
在路径上找到它,我很确定它位于 ,/bin/php
您可以通过运行来验证它:
/bin/php -v
Run that exact command—don't remove any slashes or append -cli
.
运行那个确切的命令——不要删除任何斜杠或附加-cli
.
If your script, whatever it looks like, cannot find it, it's either doing it wrong or it's missing the appropriate permissions.
如果您的脚本,无论看起来如何,都找不到它,要么是做错了,要么是缺少适当的权限。
回答by kwolfe
try the following to find it:
尝试以下方法找到它:
sudo find / -name php-cli
You most likely want php instead of php-cli though.
不过,您很可能需要 php 而不是 php-cli。
回答by sketchyTech
None of the solutions on this page found the installed versions of PHP that were present in my own elusive search for php-cli. The solution for me was to use the following command:
此页面上的所有解决方案均未找到我自己难以捉摸的 php-cli 搜索中存在的已安装 PHP 版本。我的解决方案是使用以下命令:
locate bin/php
This listed all php versions and I could then replace php
with, for example:
这列出了所有 php 版本,然后我可以替换php
为,例如:
/usr/bin/php71-cli
To access the command line interface version of php rather than the default cgi one. I then alias my instructions like so:
访问 php 的命令行界面版本而不是默认的 cgi 版本。然后我将我的指令别名如下:
alias composer='/usr/bin/php71-cli bin/composer.phar'
回答by mysolution
I installed "drush" for my drupal website. when I tried to run "drush":
我为我的 Drupal 网站安装了“drush”。当我尝试运行“drush”时:
[root@server /]# drush
/usr/share/drush/drush.launcher: line 132: /usr/bin/php-cli: No such file or directory
[root@server /]#
php-cli was not in my default directory /usr/bin
php-cli 不在我的默认目录 /usr/bin 中
Solution was to copy my "php"-file to "php-cli" file (no rename!!, just copy)
解决方案是将我的“php”文件复制到“php-cli”文件(不重命名!!,只需复制)
[root@server /]# cp php php-cli
weird, but still working!
奇怪,但仍然有效!