Install PHP 8 on AWS
Amazon Linux 2

Image from

PHP 8 is finally here, and it’s time to upgrade our DEV environments to start resolving all those Warnings :)

At Lnk.Bio we use the official AWS Amazon Linux 2 AMI, and usually rely on the library Amazon Linux Extras to update/switch php version, but PHP 8 is yet to be included (and I couldn’t find any timeline anywhere).

Therefore, I found the best way to install PHP 8 is to rely on Remi’s RPM repository which features all major PHP versions for RHEL/Centos (on which Amazon Linux 2 AMI is sort of based).

The steps are quite easy:
1. Remove current PHP versions
2. Add Remi’s RPM repo for Centos 7
3. Install PHP 8
4. Install PHP 8 additional libraries
5. Paths/Configuration Notes

Please note that this guide is not intended for those who want to run multiple PHP versions at the same time. It will replace the current PHP version with PHP 8.

Let’s go

1. Remove current PHP version

If you don’t have a formal documentation (you should!) of which additional PHP packages you need for your app, you can get a list by running.

sudo yum list installed | grep php

Once you’re confident you can reinstall everything, start by removing old PHP packages.

sudo yum remove php*

2. Add Remi’s RPM repo for Centos 7

You will also need EPEL for Centos 7 for dependencies. I guess most people have this already enabled on Amazon Linux 2 AMI, but I am adding it anyway for clarity:

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

3. Install PHP 8

Now this is quite easy:

sudo yum install php80

4. Install PHP 8 Additional libraries

If you use additional modules/libraries, you can now install them. Naming convention remained the same, but they have the prefix php80-php-{library}

For example, if you use php-fpm you’ll run `sudo yum install php80-php-fpm`; if you need mysqlnd you’ll run `sudo yum install php80-php-mysqlnd` etc…

5. Paths/Configuration notes

Please note that Remi’s PHP will be installed under /opt and the binary is `php80`. Here are a few locations you need to know:
- PHP configuration files (php.ini, php-fpm.d etc..): /etc/opt/remi/php80/
- PHP logs: /var/opt/remi/php80/log/
- PHP Binary: /usr/bin/php80

You can of course create symlinks if you prefer.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrea Olivato

Andrea Olivato

Co-founder @Lnk.Bio — Developing stuff on the Web since 2003