[HOWTO] Get 'libsodium' working with PHP 7.2

webunity

Verified User
Joined
Sep 23, 2014
Messages
49
I come from PHP 5 (mcrypt) and need to migrate to libsodium. Even tough sodium should be part of PHP 7.2 by default, without the need for a PECL extension, all sodium function calls failed.
My DA install is 100% fresh, with only PHP 7.2 (CentOS 7 with php-fpm).

Here is what i did to make it working:

Install sodium:
Code:
yum install libsodium-devel

Reconfigure PHP (follow this guide to see how):
Code:
cd /usr/local/directadmin/custombuild
mkdir -p custom/fpm
cp -fp configure/fpm/configure.php72 custom/fpm/configure.php72
nano custom/fpm/configure.php72

Add "--with-sodium" to the file & rebuild PHP:
Code:
./build php n

Check result:
Code:
php -i | grep sodium

Should give you now output like:
Code:
Configure Command =>  './configure'  '--prefix=/usr/local/php72' '--program-suffix=72' '--enable-fpm' '--with-fpm-systemd' '--with-config-file-scan-dir=/usr/local/php72/lib/php.conf.d' '--with-curl' '--with-gd' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-libxml-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mhash' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=mysqlnd' '--with-pcre-regex=/usr/local' '--with-pdo-mysql=mysqlnd' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-xsl' '--with-zlib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-sockets' '--enable-soap' '--enable-mbstring' '--with-icu-dir=/usr/local/icu' '--with-sodium' '--enable-intl'
sodium
sodium support => enabled
libsodium headers version => 1.0.16
libsodium library version => 1.0.16

Restart PHP for apache:
Code:
/bin/systemctl restart php-fpm72

Hope this helps someone, but it would be cool if the DA script would add the '--with-sodium' dynamically if it was existing on the system.

Now continue to dive into sodium! https://blog.zend.com/2018/11/06/modern-cryptography-in-php-7-2-with-sodium
 
Last edited:
Back
Top