PHP is a popular server side scripting language created purposely for the development of Static and Dynamic Websites & Web applications. PHP are initials of (Hypertext Pre-processor), which earlier stood for Personal Home Pages. For you to be able to execute PHP scripts, PHP has to be installed. This guide will show you how you can install Install PHP 7.3 | PHP 7.2 on Oracle Linux 8.

PHP packages are available on AppStream repositories on RHEL, CentOS and Oracle Linux starting from version 8. To get the list of PHP modules available, run the command:

$ sudo yum module list php
Last metadata expiration check: 1:36:54 ago on Tue 12 May 2020 09:13:34 AM UTC.
Oracle Linux 8 Application Stream (x86_64)
Name                        Stream                         Profiles                                         Summary                                     
php                         7.2 [d]                        common [d], devel, minimal                       PHP scripting language                      
php                         7.3                            common [d], devel, minimal                       PHP scripting language                      

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

You can then install the version of PHP available on the stream shown in the results.

Install PHP 7.3 on Oracle Linux 8

To install PHP 7.3 on Oracle Linux 8, run the command:

$ sudo dnf module install php:7.3

Accept installation.

Dependencies resolved.
========================================================================================================================================================
 Package                        Architecture         Version                                                      Repository                       Size
========================================================================================================================================================
Installing group/module packages:
 php-cli                        x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                         ol8_appstream                   3.0 M
 php-common                     x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                         ol8_appstream                   661 k
 php-fpm                        x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                         ol8_appstream                   1.6 M
 php-json                       x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                         ol8_appstream                    73 k
 php-mbstring                   x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                         ol8_appstream                   609 k
 php-xml                        x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                         ol8_appstream                   187 k
Installing dependencies:
 httpd-filesystem               noarch               2.4.37-21.0.1.module+el8.2.0+5576+c083ffcb                   ol8_appstream                    36 k
 libxslt                        x86_64               1.1.32-4.0.1.el8                                             ol8_baseos_latest               250 k
 nginx-filesystem               noarch               1:1.14.1-9.0.1.module+el8.0.0+5347+9282027e                  ol8_appstream                    25 k
Installing module profiles:
 php/common                                                                                                                                            
Enabling module streams:
 httpd                                               2.4                                                                                               
 nginx                                               1.14                                                                                              
 php                                                 7.3                                                                                               

Transaction Summary
========================================================================================================================================================
Install  9 Packages

Total download size: 6.4 M
Installed size: 23 M
Is this ok [y/N]: y

Verify PHP version installed on Oracle Linux 8.

$ php --version
PHP 7.3.5 (cli) (built: Apr 30 2019 08:37:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies

Install PHP 7.2 on Oracle Linux 8

If you have PHP 7.3 module installed, remove it.

$ sudo dnf module remove php:7.3
Last metadata expiration check: 1:41:51 ago on Tue 12 May 2020 09:13:34 AM UTC.
Dependencies resolved.
========================================================================================================================================================
 Package                        Architecture         Version                                                     Repository                        Size
========================================================================================================================================================
Removing:
 php-cli                        x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                        @ol8_appstream                   9.1 M
 php-common                     x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                        @ol8_appstream                   6.4 M
 php-fpm                        x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                        @ol8_appstream                   4.6 M
 php-json                       x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                        @ol8_appstream                    45 k
 php-mbstring                   x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                        @ol8_appstream                   1.6 M
 php-xml                        x86_64               7.3.5-5.module+el8.2.0+5569+98c8b30d                        @ol8_appstream                   441 k
Removing unused dependencies:
 httpd-filesystem               noarch               2.4.37-21.0.1.module+el8.2.0+5576+c083ffcb                  @ol8_appstream                   400  
 libxslt                        x86_64               1.1.32-4.0.1.el8                                            @ol8_baseos_latest               734 k
 nginx-filesystem               noarch               1:1.14.1-9.0.1.module+el8.0.0+5347+9282027e                 @ol8_appstream                     0  
Disabling module profiles:
 php/common                                                                                                                                            

Transaction Summary
========================================================================================================================================================
Remove  9 Packages

Freed space: 23 M
Is this ok [y/N]: y

The reset PHP module.

$ sudo dnf module reset php
Last metadata expiration check: 1:42:38 ago on Tue 12 May 2020 09:13:34 AM UTC.
Dependencies resolved.
========================================================================================================================================================
 Package                             Architecture                       Version                               Repository                           Size
========================================================================================================================================================
Resetting modules:
 php                                                                                                                                                   

Transaction Summary
========================================================================================================================================================

Is this ok [y/N]: y

You can then install PHP 7.2 on Oracle Linux 8.

$ sudo dnf module install php:7.2
Last metadata expiration check: 1:49:16 ago on Tue 12 May 2020 09:13:34 AM UTC.
Dependencies resolved.
========================================================================================================================================================
 Package                        Architecture         Version                                                      Repository                       Size
========================================================================================================================================================
Installing group/module packages:
 php-cli                        x86_64               7.2.24-1.module+el8.2.0+5510+6771133c                        ol8_appstream                   3.1 M
 php-common                     x86_64               7.2.24-1.module+el8.2.0+5510+6771133c                        ol8_appstream                   662 k
 php-fpm                        x86_64               7.2.24-1.module+el8.2.0+5510+6771133c                        ol8_appstream                   1.6 M
 php-json                       x86_64               7.2.24-1.module+el8.2.0+5510+6771133c                        ol8_appstream                    74 k
 php-mbstring                   x86_64               7.2.24-1.module+el8.2.0+5510+6771133c                        ol8_appstream                   581 k
 php-xml                        x86_64               7.2.24-1.module+el8.2.0+5510+6771133c                        ol8_appstream                   189 k
Installing dependencies:
 httpd-filesystem               noarch               2.4.37-21.0.1.module+el8.2.0+5576+c083ffcb                   ol8_appstream                    36 k
 libxslt                        x86_64               1.1.32-4.0.1.el8                                             ol8_baseos_latest               250 k
 nginx-filesystem               noarch               1:1.14.1-9.0.1.module+el8.0.0+5347+9282027e                  ol8_appstream                    25 k
Installing module profiles:
 php/common                                                                                                                                            
Enabling module streams:
 php                                                 7.2                                                                                               

Transaction Summary
========================================================================================================================================================
Install  9 Packages

Total download size: 6.5 M
Installed size: 25 M
Is this ok [y/N]: y

Check PHP Version on Oracle Linux 8

$ php --version
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Install other PHP extensions with the command option:

sudo dnf install php-<extension>

Example:

$ sudo dnf install php-zip php-mysqlnd
Last metadata expiration check: 2:00:27 ago on Tue 12 May 2020 09:13:34 AM UTC.
Dependencies resolved.
========================================================================================================================================================
 Package                        Architecture             Version                                                  Repository                       Size
========================================================================================================================================================
Installing:
 php-mysqlnd                    x86_64                   7.2.24-1.module+el8.2.0+5510+6771133c                    ol8_appstream                   191 k
 php-pecl-zip                   x86_64                   1.15.3-1.module+el8+5148+a558e3ee                        ol8_appstream                    51 k
Installing dependencies:
 libzip                         x86_64                   1.5.1-2.module+el8.2.0+5510+6771133c                     ol8_appstream                    63 k
 php-pdo                        x86_64                   7.2.24-1.module+el8.2.0+5510+6771133c                    ol8_appstream                   123 k

Transaction Summary
========================================================================================================================================================
Install  4 Packages

Total download size: 428 k
Installed size: 1.0 M
Is this ok [y/N]: y

Enjoy PHP Applications development on Oracle Linux 8.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

20 + 3 =