Score:0

How to install PHP Sodium on Ubuntu 22.04

kw flag

I'm running a Google Cloud server running Ubuntu 22.04. It's a typical LAMP stack (PHP is version 8.1.2). Some of the websites on the server are using Laravel 8.

I recently upgraded one of the websites to Laravel 9 and I received the following error:

Class 'Facade\Ignition\IgnitionServiceProvider' not found

From a little bit of research, apparently this is caused by a PHP extension Sodium missing.

If I run php -i | grep sodium using a terminal I get:

PHP Warning:  PHP Startup: Unable to load dynamic library 'sodium' (tried: /usr/lib/php/20210902/sodium (/usr/lib/php/20210902/sodium: cannot open shared object file: No such file or directory), /usr/lib/php/20210902/sodium.so (/usr/lib/php/20210902/sodium.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
sodium
sodium support => enabled
libsodium headers version => 1.0.18
libsodium library version => 1.0.18
PWD => /home/thomasadam83/libsodium-stable
$_SERVER['PWD'] => /home/thomasadam83/libsodium-stable

I tried installing Sodium using:

sudo apt install php-sodium

And received the following response:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package php-sodium

If I run any PHP commands form the terminal, the response starts with:

PHP Warning:  PHP Startup: Unable to load dynamic library 'sodium' (tried: /usr/lib/php/20210902/sodium (/usr/lib/php/20210902/sodium: cannot open shared object file: No such file or directory), /usr/lib/php/20210902/sodium.so (/usr/lib/php/20210902/sodium.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

I can't find any other posts with a similar issue and a working solution.

Any help would be appreciated!

janos avatar
br flag
Have you run `sudo apt update` before trying to install?
Score:0
in flag

In Ubuntu 22.04 the php8 package has sodium support directly compiled into the main package, there is no loadable library.

I assume you uncommented ;extension=sodium in php.ini. That wasn't necessary, sodium was already there. You can try that by commenting the line out again, then run a simple PHP script using a sodium function, for example:

<?php
$result = sodium_compare(452654236423,647382647836);
var_dump($result);

You should see a result, without an error.

$ php test.php
int(-1)

If that is the case your problem is not missing sodium support, it's something else.

Adam avatar
kw flag
Everything you said was accurate! Thanks! I commented out `;extension=sodium` and fixed the original problem another way.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.