`哪个 php` 无法在 linode 服务器(Ubuntu 10.04)上运行?

`哪个 php` 无法在 linode 服务器(Ubuntu 10.04)上运行?

目前正在尝试配置在 ubuntu 10.04 上运行的 linode 服务器。我利用了一个 stackscript (默认 Drupal 配置文件) 似乎运行成功。日志也表明如此。

然后通过 ssh 进入服务器(以 root 身份)尝试配置 php。

当我运行 a 时which phpwhich php5它们都没有返回任何内容。which python但是 A 返回了一些内容。

我知道 php 的默认路径在哪里,但我通常只是想用它来确认 php 存在。

我是否必须修改一些配置才能使其which工作?此外,当我使用 apt-get install 时,Tab 补全功能似乎不起作用?

更新:

谢谢大家的建议。我运行了几个命令,但也没有成功:

[ root@  ~ ]
$ dpkg -l |grep php
[ root@  ~ ]
$ apt-get install php5-cli
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php5-cli is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package php5-cli has no installation candidate

然后我尝试安装 php 和 php cli:

[ root@  ~ ]
$ sudo apt-get install php5 php5-cli
sudo: unable to resolve host xxxxxxx
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package php5 has no installation candidate

答案1

这是我期望看到的行为,在我最近安装的 10.04 上,我看到的行为如下:

$ which python
/usr/bin/python
$ which php
$ echo $? #prints exit status of most recent command
1

来自 which 手册页:

如果找到并可执行所有指定命令,则退出状态为 0

   1      if one or more specified commands is nonexistent or not executable

   2      if an invalid option is specified

最可能的原因是您没有安装 php,或者至少没有在您的 $PATH 中安装。

答案2

就像我在评论中说的那样,很有可能 PHP 根本没有安装。有两个相关的包:php5 和 php5-cli。后者允许您直接从命令行执行 php 文件:

platinum:~# apt-get remove php5-cli
platinum:~# which php
platinum:~#
platinum:~# apt-get install php5-cli
platinum:~# which php
/usr/bin/php
platinum:~#

答案3

我认为您的 Ubuntu 机器上目前没有安装 PHP。需要安装 2 个 PHP 包 - 即 php5 和 php5-cli,使用以下命令(如果您不是 root,请不要忘记“sudo”)

sudo apt-get install php5
sudo apt-get install php5-cli

此外,还可以考虑安装其他可能需要的相关软件包,如与 Apache 2 集成的 libapache2-mod-php5 和与 PEAR 集成的 php-pear。

sudo apt-get install libapache2-mod-php5 php-pear

相关内容