Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save OneYX/83f0c21735f86a57fb1e48bd556d4c50 to your computer and use it in GitHub Desktop.
Save OneYX/83f0c21735f86a57fb1e48bd556d4c50 to your computer and use it in GitHub Desktop.
Install php5.6 on Centos 7

Install php5.6 on Centos 7

Remi's RPM repository - Configuration wizard, PHP on CentOS 7 (PHP-FPM)

Command to install the Remi repository configuration package:

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Command to install the yum-utils package (for the yum-config-manager command):

yum install yum-utils

The php56 collection is available in the remi-safe repository

Command to install:

yum install php56

Command to install additional packages:

yum install php56-php-xxx

yum install php56-php-mbstring php56-php-memcache php56-php-redis  php56-php-mysqli php56-php-pdo

Command to check the installed version and available extensions:

php56 --version

php56 --modules

Enable php-fpm:

vi /etc/yum.repos.d/remi.repo

Find [remi] and [remi-php56] block, enable this repository, you have to change enabled=0 into enabled=1, after the change the blocks look like this:

[remi]
name=Remi’s RPM repository for Enterprise Linux 7 – $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
…
[remi-php56]
name=Remi’s PHP 5.6 RPM repository for Enterprise Linux 7 – $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/7/php56/mirror
# WARNING: If you enable this repository, you must also enable “remi”
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

Save the file. You are now ready to install PHP-FPM

yum install php-fpm

To ensure it also starts automatically with the server, run the following command:

systemctl enable php-fpm

Running:

systemctl start php-fpm

@OneYX
Copy link
Author

OneYX commented Mar 8, 2019

如何在CentOS 7上安装PHP 5.6
作者:Aaron Kili | 发布时间:2018年5月26日| 最后更新时间:2018年5月19日

立即下载您的免费电子书 - 为管理员提供10本免费的Linux电子书 | 4个免费的Shell脚本电子书
默认情况下,CentOS 7官方软件包存储库具有PHP 5.4,已经达到使用寿命并且不再由开发人员主动维护。要了解最新功能和安全更新,您需要在CentOS 7系统上使用更新的(可能是最新的)PHP版本。

因此,强烈建议您在CentOS 7 Linux发行版上升级或安装最新支持的PHP 5.5,PHP 5.6或PHP 7稳定版本。

在本文中,我们将解释如何在CentOS 7上安装受支持的稳定版PHP 5.5(仅提供安全更新)或PHP 5.6(相同的说明也适用于RHEL 7)。

在CentOS 7上安装PHP 5.6
1.要安装PHP 5.6,您必须使用以下命令为您的CentOS 7系统安装和启用EPEL和Remi存储库。

#yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2.接下来,安装yum-utils,它是与yum集成的各种实用程序,以增强其默认功能,为其提供更高级的包管理选项,并使其更易于使用。

它的一些重要功能包括操作存储库,在运行中启用或禁用包等,而无需任何手动配置。

#yum install yum-utils
3. yum-utils提供的最重要的程序之一是yum-config-manager,您可以使用它来激活Remi存储库作为安装各种PHP版本的默认存储库。例如,如果要在CentOS 7上安装PHP 5.5,PHP 5.6或PHP 7.2,只需启用它并如图所示进行安装。

#yum-config-manager --enable remi-php55 [ 安装PHP 5.5 ]
#yum-config-manager --enable remi-php56 [ 安装PHP 5.6 ]
#yum-config-manager --enable remi-php72 [ 安装PHP 7.2 ]
4.现在您已经启用了PHP的选定版本,您可以安装PHP(这里,我们选择安装PHP 5.6)以及所有需要的模块,如下所示

#yum-config-manager --enable remi-php56 [ 安装PHP 5.6 ]
#yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
需要注意的重要事项:

如果您出于某种原因想要降级PHP版本,则需要删除现有的PHP版本,然后使用所需的模块重新安装新的PHP。
您也可以在Linux上安装多个版本的PHP,并手动选择默认使用的版本。
然后,仔细检查系统上已安装的PHP版本。

#php -v
最后,请记住阅读这些有用的PHP文章:

如何在Linux命令行中使用和执行PHP代码
如何查找MySQL,PHP和Apache配置文件
如何使用脚本测试PHP MySQL数据库连接
如何使用Cron以普通用户身份运行PHP脚本
这就是现在!要与我们分享任何想法,您可以使用下面的评论表。接下来,我们将引导您在CentOS 6中安装PHP 7。在此之前,请与Tecmint.com保持联系。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment