dbsa@dbsa-X406UA:~$ ssh root@172.16.71.160
root@172.16.71.160's password:
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Tue Nov 21 09:38:10 2023 from 172.17.10.49
[root@devappgold ~]#
# sudo subscription-manager register
# sudo subscription-manager refresh# sudo subscription-manager attach --auto
# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
# dnf makecache
# dnf install -y httpd
# dnf install -y php56 php56-php-fpm
# systemctl enable --now httpd.service php56-php-fpm.service
# rpm -qa | grep php
# cd /var/www/html/
# echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php
==============================
Installing Docker CE and Docker compose on RHEL8
Learn how to install ocker CE and Docker compose on Red Hat Enterprise Linux (RHEL) 8 using dnf or yum commands. You can also find information about resolving Docker CE container connectivity issue in this section.
Install Docker CE and Docker compose on RHEL 8 using dnf commands
Before you begin: You need a valid Red Hat subscription and account credentials to perform these actions.
To install Docker CE and Docker compose on RHEL 8:
- Add a subscription on a RHEL 8 system. To do that, complete the following steps:
- Register the system:
This command prompts you to enter your Red Hat account credentials. After successful registration, the system is associated with your Red Hat account.sudo subscription-manager register
- Refresh:
This command manually refreshes the local system's subscription information.sudo subscription-manager refresh
- Attach a subscription:
This command automatically attaches available subscriptions to your system.sudo subscription-manager attach --auto
- Register the system:
This article will show you how to install multiple versions of PHP on Red Hat Enterprise Linux (RHEL) 8.
Table of Contents:
- Problem Definition
- Environment Specification
- Installing Third Party Yum Repositories
- Install Apache Web Server on RHEL 8
- Install Multiple PHP Versions on RHEL 8
- Conclusion
Problem Definition:
It is a very common scenario for web hosting companies to host websites of different PHP versions. To implement it, they use different Apache handlers, according to their requirements. The two most commonly used implementations are DSO and PHP-FPM.
Although tradional DSO (mod_php) handler is simple to implement and the fastest way to run PHP web applications, but it has its own pros and cons like DSO was not built to run multiple PHP versions.
FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites. Using this handler, the system will run PHP scripts as the user that owns the domain/subdomain. Each FPM pool can have independent settings.
In this guide, you will see how to implement two versions of PHP on a single Apache web servers by using PHP-FPM and mod_fcgid handler. For a quick reference, you can buy following short book, it is very comprehensive and to the point and will guide you about the implementation of Apache and PHP-FPM. (PAID LINK)
Environment Specification:
We are using a minimal RHEL 8 virtual machine with following specifications.
- CPU - 3.4 Ghz (2 cores)
- Memory - 2 GB
- Storage - 60 GB
- Operating System - RHEL 8.3
- Hostname – apache-01.centlinux.com
- IP Address - 192.168.116.206 /24
Installing Third Party Yum Repositories:
Connect with apache-01.centlinux.com as root user by using a ssh client.
Install EPEL (Extra Packages for Enterprise Linux) yum repository by using following command.
[root@apache-01 ~]# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Updating Subscription Management repositories.
Last metadata expiration check: 0:13:17 ago on Sun 14 Mar 2021 10:54:57 AM EDT.
epel-release-latest-8.noarch.rpm 7.3 kB/s | 22 kB 00:03
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
epel-release noarch 8-10.el8 @commandline 22 k
Transaction Summary
================================================================================
Install 1 Package
Total size: 22 k
Installed size: 32 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : epel-release-8-10.el8.noarch 1/1
Running scriptlet: epel-release-8-10.el8.noarch 1/1
Verifying : epel-release-8-10.el8.noarch 1/1
Installed products updated.
Installed:
epel-release-8-10.el8.noarch
Complete!
Here, we need to install PHP 5.6 and PHP 7.4. Both of these versions are available in Remi Yum repository. Therefore, we are installing Remi yum repository on our RHEL 8 server by using dnf command.
[root@apache-01 ~]# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Updating Subscription Management repositories.
Extra Packages for Enterprise Linux Modular 8 - 113 kB/s | 556 kB 00:04
Extra Packages for Enterprise Linux 8 - x86_64 80 kB/s | 8.9 MB 01:53
Last metadata expiration check: 0:00:02 ago on Sun 14 Mar 2021 11:11:46 AM EDT.
remi-release-8.rpm 11 kB/s | 25 kB 00:02
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
remi-release noarch 8.3-1.el8.remi @commandline 25 k
Transaction Summary
================================================================================
Install 1 Package
Total size: 25 k
Installed size: 20 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : remi-release-8.3-1.el8.remi.noarch 1/1
Verifying : remi-release-8.3-1.el8.remi.noarch 1/1
Installed products updated.
Installed:
remi-release-8.3-1.el8.remi.noarch
Complete!
Build yum cache for newly installed yum repositories.
[root@apache-01 ~]# dnf makecache
Updating Subscription Management repositories.
Extra Packages for Enterprise Linux Modular 8 - 2.2 kB/s | 9.5 kB 00:04
Extra Packages for Enterprise Linux 8 - x86_64 1.9 kB/s | 6.0 kB 00:03
Red Hat Enterprise Linux 8 for x86_64 - BaseOS 1.4 kB/s | 4.1 kB 00:02
Red Hat Enterprise Linux 8 for x86_64 - AppStre 2.1 kB/s | 4.5 kB 00:02
Remi's Modular repository for Enterprise Linux 26 kB/s | 740 kB 00:27
Safe Remi's RPM repository for Enterprise Linux 213 kB/s | 1.7 MB 00:07
Metadata cache created.
Install Apache Web Server on RHEL 8:
In Red Hat based Linux distributions, Apache web server is provided with httpd software package. Therefore, you are required to install it to enable web services.
[root@apache-01 ~]# dnf install -y httpd
Updating Subscription Management repositories.
Last metadata expiration check: 0:01:13 ago on Sun 14 Mar 2021 11:17:18 AM EDT.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.4.37-30.module+el8.3.0+7001+0766b9e7
rhel-8-for-x86_64-appstream-rpms 1.4 M
Installing dependencies:
apr x86_64 1.6.3-11.el8 rhel-8-for-x86_64-appstream-rpms 125 k
apr-util x86_64 1.6.1-6.el8 rhel-8-for-x86_64-appstream-rpms 105 k
httpd-filesystem noarch 2.4.37-30.module+el8.3.0+7001+0766b9e7
rhel-8-for-x86_64-appstream-rpms 37 k
httpd-tools x86_64 2.4.37-30.module+el8.3.0+7001+0766b9e7
rhel-8-for-x86_64-appstream-rpms 104 k
mailcap noarch 2.1.48-3.el8 rhel-8-for-x86_64-baseos-rpms 39 k
mod_http2 x86_64 1.15.7-2.module+el8.3.0+7670+8bf57d29
rhel-8-for-x86_64-appstream-rpms 154 k
redhat-logos-httpd noarch 81.1-1.el8 rhel-8-for-x86_64-baseos-rpms 26 k
Installing weak dependencies:
apr-util-bdb x86_64 1.6.1-6.el8 rhel-8-for-x86_64-appstream-rpms 25 k
apr-util-openssl x86_64 1.6.1-6.el8 rhel-8-for-x86_64-appstream-rpms 27 k
Enabling module streams:
httpd 2.4
Transaction Summary
================================================================================
Install 10 Packages
Total download size: 2.0 M
Installed size: 5.4 M
Downloading Packages:
(1/10): redhat-logos-httpd-81.1-1.el8.noarch.rp 8.5 kB/s | 26 kB 00:03
(2/10): apr-util-bdb-1.6.1-6.el8.x86_64.rpm 17 kB/s | 25 kB 00:01
(3/10): apr-util-openssl-1.6.1-6.el8.x86_64.rpm 5.3 kB/s | 27 kB 00:05
(4/10): mailcap-2.1.48-3.el8.noarch.rpm 7.5 kB/s | 39 kB 00:05
(5/10): apr-util-1.6.1-6.el8.x86_64.rpm 44 kB/s | 105 kB 00:02
(6/10): httpd-filesystem-2.4.37-30.module+el8.3 17 kB/s | 37 kB 00:02
(7/10): httpd-tools-2.4.37-30.module+el8.3.0+70 27 kB/s | 104 kB 00:03
(8/10): mod_http2-1.15.7-2.module+el8.3.0+7670+ 35 kB/s | 154 kB 00:04
(9/10): apr-1.6.3-11.el8.x86_64.rpm 39 kB/s | 125 kB 00:03
(10/10): httpd-2.4.37-30.module+el8.3.0+7001+07 78 kB/s | 1.4 MB 00:18
--------------------------------------------------------------------------------
Total 89 kB/s | 2.0 MB 00:23
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : apr-1.6.3-11.el8.x86_64 1/10
Running scriptlet: apr-1.6.3-11.el8.x86_64 1/10
Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/10
Installing : apr-util-1.6.1-6.el8.x86_64 3/10
Running scriptlet: apr-util-1.6.1-6.el8.x86_64 3/10
Installing : apr-util-openssl-1.6.1-6.el8.x86_64 4/10
Installing : httpd-tools-2.4.37-30.module+el8.3.0+7001+0766b9e7 5/10
Running scriptlet: httpd-filesystem-2.4.37-30.module+el8.3.0+7001+076 6/10
Installing : httpd-filesystem-2.4.37-30.module+el8.3.0+7001+076 6/10
Installing : redhat-logos-httpd-81.1-1.el8.noarch 7/10
Installing : mailcap-2.1.48-3.el8.noarch 8/10
Installing : mod_http2-1.15.7-2.module+el8.3.0+7670+8bf57d29.x8 9/10
Installing : httpd-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_6 10/10
Running scriptlet: httpd-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_6 10/10
Verifying : mailcap-2.1.48-3.el8.noarch 1/10
Verifying : redhat-logos-httpd-81.1-1.el8.noarch 2/10
Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 3/10
Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 4/10
Verifying : apr-util-1.6.1-6.el8.x86_64 5/10
Verifying : httpd-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_6 6/10
Verifying : httpd-filesystem-2.4.37-30.module+el8.3.0+7001+076 7/10
Verifying : mod_http2-1.15.7-2.module+el8.3.0+7670+8bf57d29.x8 8/10
Verifying : httpd-tools-2.4.37-30.module+el8.3.0+7001+0766b9e7 9/10
Verifying : apr-1.6.3-11.el8.x86_64 10/10
Installed products updated.
Installed:
apr-1.6.3-11.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
httpd-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_64
httpd-filesystem-2.4.37-30.module+el8.3.0+7001+0766b9e7.noarch
httpd-tools-2.4.37-30.module+el8.3.0+7001+0766b9e7.x86_64
mailcap-2.1.48-3.el8.noarch
mod_http2-1.15.7-2.module+el8.3.0+7670+8bf57d29.x86_64
redhat-logos-httpd-81.1-1.el8.noarch
Complete!
Install Multiple PHP Versions on RHEL 8:
You can easily install different versions of PHP from Remi yum repository. We are installing PHP 5.6, the oldest available version right now.
[root@apache-01 ~]# dnf install -y php56 php56-php-fpm
Updating Subscription Management repositories.
Last metadata expiration check: 0:17:47 ago on Sun 14 Mar 2021 11:17:18 AM EDT.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php56 x86_64 3.0-1.el8.remi remi-safe 8.2 k
php56-php-fpm x86_64 5.6.40-25.el8.remi remi-safe 1.4 M
Installing dependencies:
checkpolicy x86_64 2.9-1.el8 rhel-8-for-x86_64-baseos-rpms 346 k
environment-modules
x86_64 4.5.2-1.el8 rhel-8-for-x86_64-baseos-rpms 421 k
php56-libzip x86_64 1.7.3-2.el8.remi remi-safe 66 k
php56-php-cli x86_64 5.6.40-25.el8.remi remi-safe 2.7 M
php56-php-common x86_64 5.6.40-25.el8.remi remi-safe 711 k
php56-php-pear noarch 1:1.10.12-5.el8.remi
remi-safe 366 k
php56-php-pecl-jsonc
x86_64 1.3.10-3.el8.remi remi-safe 51 k
php56-php-pecl-zip
x86_64 1.19.2-1.el8.remi remi-safe 55 k
php56-php-process
x86_64 5.6.40-25.el8.remi remi-safe 74 k
php56-php-xml x86_64 5.6.40-25.el8.remi remi-safe 179 k
php56-runtime x86_64 3.0-1.el8.remi remi-safe 1.1 M
policycoreutils-python-utils
noarch 2.9-9.el8 rhel-8-for-x86_64-baseos-rpms 251 k
python3-audit x86_64 3.0-0.17.20191104git1c2f876.el8
rhel-8-for-x86_64-baseos-rpms 86 k
python3-libsemanage
x86_64 2.9-3.el8 rhel-8-for-x86_64-baseos-rpms 127 k
python3-policycoreutils
noarch 2.9-9.el8 rhel-8-for-x86_64-baseos-rpms 2.2 M
python3-setools x86_64 4.3.0-2.el8 rhel-8-for-x86_64-baseos-rpms 626 k
scl-utils x86_64 1:2.0.2-12.el8 rhel-8-for-x86_64-appstream-rpms
47 k
tcl x86_64 1:8.6.8-2.el8 rhel-8-for-x86_64-baseos-rpms 1.1 M
Transaction Summary
================================================================================
Install 20 Packages
Total download size: 12 M
Installed size: 37 M
Downloading Packages:
(1/20): checkpolicy-2.9-1.el8.x86_64.rpm 25 kB/s | 346 kB 00:14
(2/20): policycoreutils-python-utils-2.9-9.el8. 57 kB/s | 251 kB 00:04
(3/20): python3-audit-3.0-0.17.20191104git1c2f8 56 kB/s | 86 kB 00:01
(4/20): tcl-8.6.8-2.el8.x86_64.rpm 45 kB/s | 1.1 MB 00:25
(5/20): environment-modules-4.5.2-1.el8.x86_64. 79 kB/s | 421 kB 00:05
(6/20): python3-libsemanage-2.9-3.el8.x86_64.rp 40 kB/s | 127 kB 00:03
(7/20): scl-utils-2.0.2-12.el8.x86_64.rpm 30 kB/s | 47 kB 00:01
(8/20): php56-3.0-1.el8.remi.x86_64.rpm 4.5 kB/s | 8.2 kB 00:01
(9/20): python3-setools-4.3.0-2.el8.x86_64.rpm 91 kB/s | 626 kB 00:06
(10/20): php56-libzip-1.7.3-2.el8.remi.x86_64.r 26 kB/s | 66 kB 00:02
(11/20): python3-policycoreutils-2.9-9.el8.noar 67 kB/s | 2.2 MB 00:34
(12/20): php56-php-common-5.6.40-25.el8.remi.x8 68 kB/s | 711 kB 00:10
(13/20): php56-php-pear-1.10.12-5.el8.remi.noar 51 kB/s | 366 kB 00:07
(14/20): php56-php-pecl-jsonc-1.3.10-3.el8.remi 39 kB/s | 51 kB 00:01
(15/20): php56-php-pecl-zip-1.19.2-1.el8.remi.x 29 kB/s | 55 kB 00:01
(16/20): php56-php-process-5.6.40-25.el8.remi.x 37 kB/s | 74 kB 00:02
(17/20): php56-php-xml-5.6.40-25.el8.remi.x86_6 60 kB/s | 179 kB 00:02
(18/20): php56-php-fpm-5.6.40-25.el8.remi.x86_6 38 kB/s | 1.4 MB 00:38
(19/20): php56-php-cli-5.6.40-25.el8.remi.x86_6 53 kB/s | 2.7 MB 00:52
(20/20): php56-runtime-3.0-1.el8.remi.x86_64.rp 42 kB/s | 1.1 MB 00:28
--------------------------------------------------------------------------------
Total 131 kB/s | 12 MB 01:33
warning: /var/cache/dnf/remi-safe-ff04689114f71b24/packages/php56-3.0-1.el8.remi.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 5f11735a: NOKEY
Safe Remi's RPM repository for Enterprise Linux 3.0 MB/s | 3.1 kB 00:00
Importing GPG key 0x5F11735A:
Userid : "Remi's RPM repository <remi@remirepo.net>"
Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : python3-setools-4.3.0-2.el8.x86_64 1/20
Installing : python3-libsemanage-2.9-3.el8.x86_64 2/20
Installing : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_ 3/20
Installing : checkpolicy-2.9-1.el8.x86_64 4/20
Installing : python3-policycoreutils-2.9-9.el8.noarch 5/20
Installing : policycoreutils-python-utils-2.9-9.el8.noarch 6/20
Installing : tcl-1:8.6.8-2.el8.x86_64 7/20
Running scriptlet: tcl-1:8.6.8-2.el8.x86_64 7/20
Installing : environment-modules-4.5.2-1.el8.x86_64 8/20
Running scriptlet: environment-modules-4.5.2-1.el8.x86_64 8/20
Installing : scl-utils-1:2.0.2-12.el8.x86_64 9/20
Installing : php56-runtime-3.0-1.el8.remi.x86_64 10/20
Running scriptlet: php56-runtime-3.0-1.el8.remi.x86_64 10/20
Installing : php56-libzip-1.7.3-2.el8.remi.x86_64 11/20
Installing : php56-php-pecl-jsonc-1.3.10-3.el8.remi.x86_64 12/20
Installing : php56-php-common-5.6.40-25.el8.remi.x86_64 13/20
Installing : php56-php-pecl-zip-1.19.2-1.el8.remi.x86_64 14/20
Installing : php56-php-cli-5.6.40-25.el8.remi.x86_64 15/20
Installing : php56-php-process-5.6.40-25.el8.remi.x86_64 16/20
Installing : php56-php-xml-5.6.40-25.el8.remi.x86_64 17/20
Installing : php56-php-pear-1:1.10.12-5.el8.remi.noarch 18/20
Running scriptlet: php56-php-pear-1:1.10.12-5.el8.remi.noarch 18/20
Installing : php56-3.0-1.el8.remi.x86_64 19/20
Installing : php56-php-fpm-5.6.40-25.el8.remi.x86_64 20/20
Running scriptlet: php56-php-fpm-5.6.40-25.el8.remi.x86_64 20/20
Running scriptlet: php56-php-pecl-jsonc-1.3.10-3.el8.remi.x86_64 20/20
Running scriptlet: php56-php-common-5.6.40-25.el8.remi.x86_64 20/20
=====================================================================
WARNING : PHP 5.6 have reached its "End of Life" in
January 2019. Even, if this package includes some of
the important security fix, backported from 7.3, the
UPGRADE to a maintained version is very strongly RECOMMENDED.
=====================================================================
Running scriptlet: php56-php-fpm-5.6.40-25.el8.remi.x86_64 20/20
Running scriptlet: php56-php-pear-1:1.10.12-5.el8.remi.noarch 20/20
Running scriptlet: php56-php-fpm-5.6.40-25.el8.remi.x86_64 20/20
Verifying : tcl-1:8.6.8-2.el8.x86_64 1/20
Verifying : checkpolicy-2.9-1.el8.x86_64 2/20
Verifying : python3-policycoreutils-2.9-9.el8.noarch 3/20
Verifying : policycoreutils-python-utils-2.9-9.el8.noarch 4/20
Verifying : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_ 5/20
Verifying : environment-modules-4.5.2-1.el8.x86_64 6/20
Verifying : python3-libsemanage-2.9-3.el8.x86_64 7/20
Verifying : python3-setools-4.3.0-2.el8.x86_64 8/20
Verifying : scl-utils-1:2.0.2-12.el8.x86_64 9/20
Verifying : php56-3.0-1.el8.remi.x86_64 10/20
Verifying : php56-libzip-1.7.3-2.el8.remi.x86_64 11/20
Verifying : php56-php-cli-5.6.40-25.el8.remi.x86_64 12/20
Verifying : php56-php-common-5.6.40-25.el8.remi.x86_64 13/20
Verifying : php56-php-fpm-5.6.40-25.el8.remi.x86_64 14/20
Verifying : php56-php-pear-1:1.10.12-5.el8.remi.noarch 15/20
Verifying : php56-php-pecl-jsonc-1.3.10-3.el8.remi.x86_64 16/20
Verifying : php56-php-pecl-zip-1.19.2-1.el8.remi.x86_64 17/20
Verifying : php56-php-process-5.6.40-25.el8.remi.x86_64 18/20
Verifying : php56-php-xml-5.6.40-25.el8.remi.x86_64 19/20
Verifying : php56-runtime-3.0-1.el8.remi.x86_64 20/20
Installed products updated.
Installed:
checkpolicy-2.9-1.el8.x86_64
environment-modules-4.5.2-1.el8.x86_64
php56-3.0-1.el8.remi.x86_64
php56-libzip-1.7.3-2.el8.remi.x86_64
php56-php-cli-5.6.40-25.el8.remi.x86_64
php56-php-common-5.6.40-25.el8.remi.x86_64
php56-php-fpm-5.6.40-25.el8.remi.x86_64
php56-php-pear-1:1.10.12-5.el8.remi.noarch
php56-php-pecl-jsonc-1.3.10-3.el8.remi.x86_64
php56-php-pecl-zip-1.19.2-1.el8.remi.x86_64
php56-php-process-5.6.40-25.el8.remi.x86_64
php56-php-xml-5.6.40-25.el8.remi.x86_64
php56-runtime-3.0-1.el8.remi.x86_64
policycoreutils-python-utils-2.9-9.el8.noarch
python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64
python3-libsemanage-2.9-3.el8.x86_64
python3-policycoreutils-2.9-9.el8.noarch
python3-setools-4.3.0-2.el8.x86_64
scl-utils-1:2.0.2-12.el8.x86_64
tcl-1:8.6.8-2.el8.x86_64
Complete!
We are also installing the PHP 7.4, the latest available version right now.
[root@apache-01 ~]# dnf install -y php74 php74-php-fpm
Updating Subscription Management repositories.
Last metadata expiration check: 0:22:17 ago on Sun 14 Mar 2021 11:17:18 AM EDT.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php74 x86_64 1.0-3.el8.remi remi-safe 6.8 k
php74-php-fpm x86_64 7.4.16-1.el8.remi remi-safe 1.6 M
Installing dependencies:
php74-php-cli x86_64 7.4.16-1.el8.remi remi-safe 3.1 M
php74-php-common x86_64 7.4.16-1.el8.remi remi-safe 704 k
php74-php-json x86_64 7.4.16-1.el8.remi remi-safe 80 k
php74-runtime x86_64 1.0-3.el8.remi remi-safe 1.1 M
Transaction Summary
================================================================================
Install 6 Packages
Total download size: 6.6 M
Installed size: 25 M
Downloading Packages:
(1/6): php74-1.0-3.el8.remi.x86_64.rpm 6.9 kB/s | 6.8 kB 00:00
(2/6): php74-php-common-7.4.16-1.el8.remi.x86_6 45 kB/s | 704 kB 00:15
(3/6): php74-php-json-7.4.16-1.el8.remi.x86_64. 48 kB/s | 80 kB 00:01
(4/6): php74-php-fpm-7.4.16-1.el8.remi.x86_64.r 45 kB/s | 1.6 MB 00:36
(5/6): php74-runtime-1.0-3.el8.remi.x86_64.rpm 46 kB/s | 1.1 MB 00:25
(6/6): php74-php-cli-7.4.16-1.el8.remi.x86_64.r 41 kB/s | 3.1 MB 01:16
--------------------------------------------------------------------------------
Total 88 kB/s | 6.6 MB 01:17
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : php74-runtime-1.0-3.el8.remi.x86_64 1/6
Running scriptlet: php74-runtime-1.0-3.el8.remi.x86_64 1/6
Installing : php74-php-json-7.4.16-1.el8.remi.x86_64 2/6
Installing : php74-php-common-7.4.16-1.el8.remi.x86_64 3/6
Installing : php74-php-cli-7.4.16-1.el8.remi.x86_64 4/6
Installing : php74-1.0-3.el8.remi.x86_64 5/6
Installing : php74-php-fpm-7.4.16-1.el8.remi.x86_64 6/6
Running scriptlet: php74-php-fpm-7.4.16-1.el8.remi.x86_64 6/6
Verifying : php74-1.0-3.el8.remi.x86_64 1/6
Verifying : php74-php-cli-7.4.16-1.el8.remi.x86_64 2/6
Verifying : php74-php-common-7.4.16-1.el8.remi.x86_64 3/6
Verifying : php74-php-fpm-7.4.16-1.el8.remi.x86_64 4/6
Verifying : php74-php-json-7.4.16-1.el8.remi.x86_64 5/6
Verifying : php74-runtime-1.0-3.el8.remi.x86_64 6/6
Installed products updated.
Installed:
php74-1.0-3.el8.remi.x86_64
php74-php-cli-7.4.16-1.el8.remi.x86_64
php74-php-common-7.4.16-1.el8.remi.x86_64
php74-php-fpm-7.4.16-1.el8.remi.x86_64
php74-php-json-7.4.16-1.el8.remi.x86_64
php74-runtime-1.0-3.el8.remi.x86_64
Complete!
You are required to create script wrappers, to call the required version of PHP based on user request.
Execute following commands to create PHP script wrappers.
[root@apache-01 ~]# cat > /var/www/cgi-bin/php56.fcgi << EOF > #!/bin/bash > exec /bin/php56-cgi > EOF [root@apache-01 ~]# cat > /var/www/cgi-bin/php74.fcgi << EOF > #!/bin/bash > exec /bin/php74-cgi > EOF
Add execution permissions on these script files.
[root@apache-01 ~]# chmod 755 /var/www/cgi-bin/php*
Now add Apache virtual host configurations to run PHP versions websites on different ports. You can also run Virtual Hosts on different Domain names, if you have configured a authoritative DNS server for your network.
Create a configuration for PHP 5.6 based virtual host.
[root@apache-01 ~]# vi /etc/httpd/conf.d/php56.conf
Add following directives in this file.
Listen 8056 <VirtualHost *:8056> ServerAdmin root@localhost.com ServerName 56.test DocumentRoot /var/www/html DirectoryIndex index.php index.html <FilesMatch "\.php$"> <If "-f %{REQUEST_FILENAME}"> SetHandler "proxy:unix:/var/opt/remi/php56/run/php-fpm/www.sock|fcgi://localhost" </If> </FilesMatch> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" AddHandler php56-fcgi .php Action php56-fcgi /cgi-bin/php56.fcgi <Directory "/var/www/html"> AllowOverride All </Directory> </VirtualHost>
Similarly, Add configurations for PHP 7.4 base virtual host.
[root@apache-01 ~]# vi /etc/httpd/conf.d/php74.conf
Add following directives therein.
Listen 8074 <VirtualHost *:8074> ServerAdmin root@localhost.com ServerName 74.test DocumentRoot /var/www/html DirectoryIndex index.php index.html <FilesMatch "\.php$"> <If "-f %{REQUEST_FILENAME}"> SetHandler "proxy:unix:/var/opt/remi/php74/run/php-fpm/www.sock|fcgi://localhost" </If> </FilesMatch> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" AddHandler php74-fcgi .php Action php74-fcgi /cgi-bin/php74.fcgi <Directory "/var/www/html"> AllowOverride All </Directory> </VirtualHost>
Create a default index for your website.
[root@apache-01 ~]# vi /var/www/html/index.php
And add following PHP code in this file.
<?php phpinfo(); ?>
Add both virtual host ports to SELinux http_port_t port type. So, the Apache web server can start service on these ports.
[root@apache-01 ~]# semanage port -a -t http_port_t -p tcp 8056 [root@apache-01 ~]# semanage port -a -t http_port_t -p tcp 8074
Allow these service ports in Linux firewall.
[root@apache-01 ~]# firewall-cmd --permanent --add-port={8056,8074}/tcp success [root@apache-01 ~]# firewall-cmd --reload success
Enable and start the Apache and PHP-FPM services.
[root@apache-01 ~]# systemctl enable --now httpd.service php56-php-fpm.service php74-php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service â /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php56-php-fpm.service â /usr/lib/systemd/system/php56-php-fpm.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php74-php-fpm.service â /usr/lib/systemd/system/php74-php-fpm.service.
Open URL http://apache-01.centlinux.com:8056 in a web browser.
Open URL http://apache-01.centlinux.com:8074 in a web browser.
Conclusion:
In this article, you have learned how to install Multiple PHP versions on Red Hat Enterprise Linux (RHEL) 8. If you found this article too advanced, then you should buy and read Linux Command Line and Shell Scripting Bible (PAID LINK) by Richard Blum.
Tidak ada komentar:
Posting Komentar