Use the following procedure to install the libsodium library and PHP extension.
NOTE: CentOS 6 does not have a version of libsodium that is new enough to be compatible with the PHP PECL extension. It is not currently possible to use libsodium if you are using CentOS 6. If you would like to use libsodium you must create a CentOS 7 server, install cPanel, and then migrate your accounts to the new server. You can learn how to migrate your accounts here:
1. Login to the server via SSH or Terminal as the root user
2. If you do not yet already have the EPEL repository installed, you must install it. If you are using CentOS 7 you may use the following command:
yum -y install epel-release
Other operating systems may require different steps to install the EPEL repository.
3. Issue the following command to install the required libraries:
yum install libsodium libsodium-devel -y
4. Next, you can use either install the PHP extension via WHM or the command line
Install the libsodium PHP extension via the command line
- Login to the server via SSH or Terminal as the root user
- Issue the following command to find the PECL binaries for each version of PHP you have installed:
find /opt/cpanel/ -iname pecl | grep bin
- Issue the command to install the extension, modifying the path to the binary based on which version of PHP you want to install the extension for:
/opt/cpanel/ea-php74/root/usr/bin/pecl install libsodium
Install the libsodium PHP extension via WHM
- Login to WHM as the root user
- Navigate to: Home »Software »Module Installers
- Click the Manage link for PHP PECL
- Select your desired version of PHP from the drop-down and click the blue Apply button
- Put libsodium into the box under "Install a PHP PECL"
- Click the blue Install button
Verifying that the extension is loaded
You can verify that the extension is loaded by creating a PHP Info file and then examining the result. Details about how this is done can be found here: