Install PHP YAML via PECL.

PHP YAML
Ron Mac Quarrie

If you’re managing a server with WHM (Web Host Manager) and need to install the PHP-YamlReader module, you’re in the right place. During a recent update of Apache and PHP, I noticed that PHP-YamlReader was not listed among the available PHP modules. Since the client requested its installation for their web application, I needed to act quickly and gain root access through the WHM terminal.

By following this guide, you will successfully install and enable PHP-YamlReader from the command line, ensuring it’s ready for use in your applications. 

WHM's EasyApache 4 may not yet have full support for PHP 8.3 extensions, so you'll need to use PECL to install the YAML extension manually.

Step-by-Step Guide:
1. Install YAML via PECL:
Log into WHM as root.

2. Open Terminal via WHM:

Navigate to Server Configuration > Terminal.

3. Install YAML via PECL: 
First, ensure that PECL for PHP 8.3 is available by checking the PECL path:

/opt/cpanel/ea-php83/root/usr/bin/pecl version

4. Install YAML: 
Run the following PECL command to install the YAML extension for PHP 8.3:

/opt/cpanel/ea-php83/root/usr/bin/pecl install yaml

If PECL prompts you to install missing dependencies, you might need to install libyaml:

yum install libyaml libyaml-devel

5. Enable the YAML Extension
After installation, you'll need to add the YAML extension to the PHP configuration file for PHP 8.3.

echo "extension=yaml.so" > /opt/cpanel/ea-php83/root/etc/php.d/50-yaml.ini

6. Restart Apache

systemctl restart httpd

7. Verify Installation
To confirm the YAML extension is installed:

/opt/cpanel/ea-php83/root/usr/bin/php -m | grep yaml
 

You now have a working PHP-YAML extension, congratulations!