For those who seeks help in different areas of Software and Hardware platform

How To Install or Upgrade PHP on Fedora/CentOS/RHEL

This guide will show you how to install or upgrade to latest release of PHP on Fedora, RHEL and CentOS.

Note: On CentOS/RHEL 8, yum command has been replaced with dnf and in near future yum package manager will be discontinued. It is now recommended to use dnf for installing packages on CentOS/RHEL 8 but if you still wish to use yum you can use it.

Adding EPEL/Remi Repository

If you are on Fedora, standards repositories are enough, you can directly install or upgrade PHP version.  For (RHEL, CentOS) the Extra Packages for Enterprise Linux (EPEL) repository must be configured before proceeding to install, and on RHEL the optional channel must also be enabled.

For CentOS 8

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled PowerTools

sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf config-manager --set-enabled remi

For RHEL 8

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
ARCH=$( /bin/arch )
sudo dnf config-manager --set-enabled PowerTools
sudo subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms"

sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf config-manager --set-enabled remi

For CentOS 7.6

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

For RHEL 7.6

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo subscription-manager repos --enable=rhel-7-server-optional-rpms

For CentOS 6.10

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-6.rpm

For RHEL 6.10

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum -y install https://rpms.remirepo.net/enterprise/remi-release-6.rpm
rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6

For Fedora 29

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-29.rpm

For Fedora 28

sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-28.rpm

Installing PHP

For CentOS/RHEL 8, you can install any version of php with below command:
sudo dnf -y install php php-fpm
For installing specific php version, type one of the below command:
sudo dnf -y install php70
sudo dnf -y install php71
sudo dnf -y install php72
sudo dnf -y install php73
sudo dnf -y install php74
For CentOS/RHEL 7, you can install default version of php with below command:
sudo yum -y install php php-fpm
For installing specific php version, type below command:
sudo yum -y install php70
sudo yum -y install php71
sudo yum -y install php72
sudo yum -y install php73
sudo yum -y install php74
For CentOS/RHEL 6, you can install default version of php with below command:
yum -y install php php-fpm
For installing specific php version, type one of below command:
yum -y install php70
yum -y install php71
yum -y install php72
yum -y install php73
For Fedora, you can install any version of php with below command:
sudo dnf -y install dnf-plugins-core
For installing default php version, type below command:
sudo dnf -y install php php-fpm
For installing specific php version, type one of the below command:
sudo dnf -y install php70
sudo dnf -y install php71
sudo dnf -y install php72
sudo dnf -y install php73
sudo dnf -y install php74
We hope this guide was helpful.
Share:

0 comments:

Post a Comment

Comments with links will not be published.