在 Enterprise Linux 发行版中安装(CentOS Scientific Linux 等)

使用 yum 命令管理基于 Enterprise Linux 的操作系统中的软件包:

yum install php

这将安装 PHP 的最小安装,包括一些常见功能。如果你需要其他模块,则需要单独安装。再次,你可以使用 yum 搜索这些包:

yum search php-*

输出示例:

php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-cli.x86_64 : Command-line interface for PHP
php-common.x86_64 : Common files for PHP
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-devel.x86_64 : Files needed for building PHP extensions
php-embedded.x86_64 : PHP library for embedding in applications
php-enchant.x86_64 : Human Language and Character Encoding Support
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-imap.x86_64 : A module for PHP applications that use IMAP

要安装 gd 库:

yum install php-gd

企业 Linux 发行版在更新时始终保守,并且通常不会更新它们附带的版本。许多第三方存储库提供当前版本的 PHP:

IUS 和 Webtatic 提供具有不同名称的替换包(例如 php56uphp56w 以安装 PHP 5.6),而 Remi 的存储库通过使用与系统包相同的名称提供就地升级。

以下是从 Remi 的存储库安装 PHP 7.0 的说明。这是最简单的示例,因为不需要卸载系统软件包。

# download the RPMs; replace 6 with 7 in case of EL 7
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
# install the repository information
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
# enable the repository
yum-config-manager --enable epel --enable remi --enable remi-safe --enable remi-php70
# install the new version of PHP
# NOTE: if you already have the system package installed, this will update it
yum install php