How to compile PHP with AVIF support on DirectAdmin servers

Como Compilar PHP com suporte a AVIF em servidores DirectAdmin

AVIF: The Future of Image Compression on the Web

In this guide, we will discuss how to compile PHP with AVIF support on DirectAdmin servers.

AVIF (AV1 Image File Format) is a modern image file format that offers significantly higher compression compared to traditional formats such as JPEG, PNG, and even WebP. AVIF stands out for its ability to drastically reduce image file sizes while maintaining high visual quality, resulting in faster web page loading and lower data consumption.

The GD extension in PHP 8.1 and later versions supports the AVIF image format, enabling the conversion of images to and from AVIF. The GD extension on modern operating systems supported by DirectAdmin, such as CentOS, Rock Linux, AlmaLinux, Ubuntu, and Debian, is already compiled with AVIF support. However, you will need to install some requirements.

Ubuntu/Debian

RHEL/Fedora/CentOS/Almalinux/Rock Linux

After installing the dependencies, PHP can be compiled with AVIF support using the new flag

–with-avif in the ./configure.phpXX script.

We need to copy the files with the .php8x extension to the “/usr/local/directadmin/custombuild/custom/php/” folder before updating them. But first, make sure that none of the files are in the custom folder:

The expected error is:

So, let’s create the folder and copy the files:

Next, we need to correct the copied files:

Now it’s time to compile php

Once PHP has been recompiled, a final test would be to see “AVIF Support => enabled.”

“:

By following these steps, you will have AVIF support in PHP.