How To Install PHP 8.0 on Amazon Linux 2

PHP 8.0 is a major release of the PHP programming Language mostly used in the Development of Web Applications. It is the stable release and you can plan to migrate your applications but being aware that some could break especially where old features are deprecated.

In this article we will cover the installation of PHP 8 on Amazon Linux 2 server running in the Cloud or On-prem infrastructure.

Update Amazon Linux 2 system

Update the system before starting the installation of PHP 8 on Amazon Linux 2 system.

sudo yum -y update

Linux updates often comes with newer kernel patches and reboot is required for the system to run in this new release.

sudo systemctl reboot

Add EPEL and Remi Repositories

The packages and dependencies that will be required in the installation of PHP 8 on Amazon Linux 2 server are available in the EPEL and Remi repositories. The two RPM repositories need to be added manually by running the commands below in the terminal.

sudo yum -y install
sudo yum -y install yum install

Update Yum index to confirm the two repositories are working.

$ sudo yum makecache
Loaded plugins: langpacks, priorities, update-motd
amzn2-core                                                                                                                                 | 3.7 kB  00:00:00
amzn2extra-docker                                                                                                                          | 3.0 kB  00:00:00
epel/x86_64/metalink                                                                                                                       |  15 kB  00:00:00
remi-safe                                                                                                                                  | 3.0 kB  00:00:00
(1/5): epel/x86_64/filelists_db                                                                                                            |  12 MB  00:00:01
(2/5): epel/x86_64/prestodelta                                                                                                             |  547 B  00:00:00
(3/5): epel/x86_64/other_db                                                                                                                | 3.3 MB  00:00:00
(4/5): remi-safe/other_db                                                                                                                  | 491 kB  00:00:00
(5/5): remi-safe/filelists_db                                                                                                              | 1.4 MB  00:00:01
Metadata Cache Created

Install PHP 8.0 on Amazon Linux 2

Install the yum-utils package which provides yum-config-manager command line tool.

sudo yum -y install yum-utils

Disable all Remi PHP repositories.

sudo yum-config-manager --disable 'remi-php*'

Enable PHP 8 Remi repository on Amazon Linux 2:

sudo yum-config-manager --enable remi-php80

Check current list of repositories enabled.

$ sudo yum repolist
Loaded plugins: langpacks, priorities, update-motd
245 packages excluded due to repository priority protections
repo id                                                   repo name                                                                                     status
amzn2-core/2/x86_64                                       Amazon Linux 2 core repository                                                                    22,852
amzn2extra-docker/2/x86_64                                Amazon Extras repo for docker                                                                         36
epel/x86_64                                               Extra Packages for Enterprise Linux 7 - x86_64                                                13,291+195
remi-php80                                                Remi's PHP 8.0 RPM repository for Enterprise Linux 7 - x86_64                                     214+47
remi-safe                                                 Safe Remi's RPM repository for Enterprise Linux 7 - x86_64                                       4,038+3
repolist: 40,431

Install PHP 8.0 on Amazon Linux 2 using the command:

sudo yum install php80

Initiate installation by accepting to start.

Dependencies Resolved

 Package                                      Arch                         Version                                         Repository                        Size
 php80                                        x86_64                       1.0-3.el7.remi                                  remi-safe                        2.8 k
Installing for dependencies:
 audit-libs-python                            x86_64                       2.8.1-3.amzn2.1                                 amzn2-core                        79 k
 checkpolicy                                  x86_64                       2.5-6.amzn2                                     amzn2-core                       294 k
 environment-modules                          x86_64                       3.2.10-10.amzn2.0.2                             amzn2-core                       107 k
 libX11                                       x86_64                       1.6.7-3.amzn2                                   amzn2-core                       606 k
 libX11-common                                noarch                       1.6.7-3.amzn2                                   amzn2-core                       164 k
 libXau                                       x86_64                       1.0.8-2.1.amzn2.0.2                             amzn2-core                        29 k
 libcgroup                                    x86_64                       0.41-21.amzn2                                   amzn2-core                        66 k
 libselinux-python                            x86_64                       2.5-12.amzn2.0.2                                amzn2-core                       237 k
 libsemanage-python                           x86_64                       2.5-11.amzn2                                    amzn2-core                       115 k
 libxcb                                       x86_64                       1.12-1.amzn2.0.2                                amzn2-core                       216 k
 ncurses-compat-libs                          x86_64                       6.0-8.20170212.amzn2.1.3                        amzn2-core                       308 k
 php80-php-cli                                x86_64                       8.0.0-2.el7.remi                                remi-safe                        3.5 M
 php80-php-common                             x86_64                       8.0.0-2.el7.remi                                remi-safe                        704 k
 php80-runtime                                x86_64                       1.0-3.el7.remi                                  remi-safe                        1.1 M
 policycoreutils-python                       x86_64                       2.5-22.amzn2                                    amzn2-core                       454 k
 python-IPy                                   noarch                       0.75-6.amzn2.0.1                                amzn2-core                        32 k
 setools-libs                                 x86_64                       3.3.8-2.amzn2.0.2                               amzn2-core                       618 k
 tcl                                          x86_64                       1:8.5.13-8.amzn2.0.2                            amzn2-core                       1.9 M

Transaction Summary
Install  1 Package (+18 Dependent packages)

Total download size: 11 M
Installed size: 35 M
Is this ok [y/d/N]: y

Notice this installation method doesn’t affect the default installation of PHP you had on your Amazon Linux 2 server. To use PHP 8 the command is not php but php80

$ php80 --version
PHP 8.0.0 (cli) (built: Nov 24 2020 17:04:03) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

Installing PHP extensions.

sudo yum install php80-<extension>


sudo yum install php80-php-fpm php80-php-mysqlnd php80-php-json php80-php-xml php80-php-tidy php80-php-pecl-zip

Sample output:

Dependencies Resolved

 Package                                     Arch                            Version                                    Repository                           Size
 php80-php-fpm                               x86_64                          8.0.0-2.el7.remi                           remi-safe                           1.8 M
 php80-php-mysqlnd                           x86_64                          8.0.0-2.el7.remi                           remi-safe                           193 k
 php80-php-pecl-zip                          x86_64                          1.19.2-1.el7.remi                          remi-safe                            53 k
 php80-php-tidy                              x86_64                          8.0.0-2.el7.remi                           remi-safe                            76 k
 php80-php-xml                               x86_64                          8.0.0-2.el7.remi                           remi-safe                           174 k
Installing for dependencies:
 libtidy                                     x86_64                          5.4.0-1.el7                                epel                                174 k
 libxslt                                     x86_64                          1.1.28-6.amzn2                             amzn2-core                          240 k
 libzip5                                     x86_64                          1.7.3-1.el7.remi                           remi-safe                            61 k
 php80-php-pdo                               x86_64                          8.0.0-2.el7.remi                           remi-safe                           127 k

Transaction Summary
Install  5 Packages (+4 Dependent packages)

Total download size: 2.9 M
Installed size: 8.6 M
Is this ok [y/d/N]: y

Total                                                                                                                             1.5 MB/s | 2.9 MB  00:00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <[email protected]>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-13.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y

You can also search for all packages that matches php80.

sudo yum search php80

Check available extensions.

$ php80 --modules

Refer to the official PHP 8.0 release page for more reading.

See also  Git behind office proxy

Other articles on Amazon Linux:

How To Install Jenkins on Amazon Linux 2

How To Install Terraform on Amazon Linux 2

How To Install PostgreSQL 13 on Amazon Linux 2

Source link

Originally posted 2020-12-12 06:53:38.

About Mas Wahyu

Check Also

How to install and configure Anaconda on CentOS 7

How to install and configure Anaconda on CentOS 7

Anaconda is the most popular machine learning and data science tool used in large scale …

Leave a Reply