phpmcryptlibsodium

Error while installing libsodium in PHP 7.1


I'm in PHP 7.1.25 and mcrypt is the current extension used and mcrypt will be deprecated in PHP 7.2 and Libsodium will be added to the core extensions in PHP 7.2

Now I would need to try installing libsodium in PHP 7.1 and see how it works, Followed this https://lukasmestan.com/install-libsodium-extension-in-php7 but the installation failed. Updated PECL package as well. See the error below!

Any help would be really appreciated. Thanks in Advance!

$ sudo pecl install -f libsodium
downloading libsodium-2.0.20.tgz ...
Starting to download libsodium-2.0.20.tgz (28,504 bytes)
.........done: 28,504 bytes
4 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
building in /tmp/pear/temp/pear-build-rootsL5uMO/libsodium-2.0.20
running: /tmp/pear/temp/libsodium/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20160303 -I/usr/include/php/20160303/main -I/usr/include/php/20160303/TSRM -I/usr/include/php/20160303/Zend -I/usr/include/php/20160303/ext -I/usr/include/php/20160303/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20160303
checking for PHP installed headers prefix... /usr/include/php/20160303
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for sodium support... yes, shared
checking for pkg-config... no
checking for libsodium... configure: error: Please install libsodium - See https://github.com/jedisct1/libsodium
ERROR: `/tmp/pear/temp/libsodium/configure --with-php-config=/usr/bin/php-config' failed

Solution

  • @VenkateshLB You have to install the libsodium provided by your linux distribution first.

    CentOS 7:

    yum install libsodium libsodium-devel
    

    Ubuntu 18.04:

    apt install libsodium libsodium-dev
    

    When installed, execute the PECL command.