Ubuntu – PHP Fatal error: sodium_init() in Unknown on line 0

18.04PHPphp7

When I run any php script I get an error sodium_init() in Unknown on line 0.

Use Ubuntu 18.04, PHP 7.2.10

Examples:

admin@server:~$ php -v
PHP Fatal error:  sodium_init() in Unknown on line 0
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

or Composer:

admin@server:~$ php composer.phar
PHP Fatal error:  sodium_init() in Unknown on line 0
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                        /_/
Composer version 1.8.3 2019-01-30 08:31:33
...

libsodium installed:

php-libsodium/bionic,bionic,now 1.0.6-1build3 amd64 [installed]
libsodium-dev/bionic,now 1.0.16-2 amd64 [installed]
libsodium23/bionic,now 1.0.16-2 amd64 [installed]

Best Answer

sudo apt remove php-libsodium

The modern Sodium cryptography library has now become a core extension in PHP. http://php.net/manual/en/migration72.new-features.php