'How to install PHP 8.1 on Amazon Linux 2 (ARM64)

I'm trying to install php 8.1 on a Graviton 2 (ARM64) EC2 instance thats running Amazon Linux 2.

All of the guides I've followed use remi-release-7.rpm. When I use this repository, yum updates are flooded with 404 errors like

http://rpms.remirepo.net/enterprise/7/safe/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

Is there a relatively easy way to install PHP 8.1 on this type of instance?



Solution 1:[1]

You can build it from source. I was able to install it on Amazon Linux 2 on Graviton (aarch64, 5.10 kernel) using the steps below. Be sure to update the url in the wget command to the latest available version or what ever you want to build.

sudo yum -y groupinstall "Development Tools" "Development Libraries"
sudo yum -y install libxml2-devel sqlite-devel
wget https://www.php.net/distributions/php-8.1.5.tar.xz
tar -xf php-8.1.5.tar.xz
cd php-8.1.5/
./configure
make -j$(nproc)
sudo make -j$(nproc) install

Alternatively, you could just use a container. You can get one from Amazon ECR here: https://gallery.ecr.aws/docker/library/php

docker pull public.ecr.aws/docker/library/php:8.1-rc-apache-bullseye

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1