What is "sodium," which is a required component for Moodle 3.11?

What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Number of replies: 15
Picture of Particularly helpful Moodlers Picture of Testers

I noticed that Moodle 3.11 requires “sodium.”

I had success installing sodium on my VPS, but it was a strange installation.  Sodium seems to be a PHP extension, yet I could not install it like other extensions.  It appears to involve PECL, which other PHP extensions do not need.  I had to install it by issuing commands in terminal.  And even after I had success, it doesn’t show anywhere in php.ini.  php.info does show it, however. 

I checked the Moodle docs for sodium, and information about it does not exist.

Could someone explain sodium?  I guess that sodium might be troublesome to installations of Moodle.  It probably needs some information in the Moodle docs, too.

As a side note, sodium already existed in my MAMP 6.3, so my installation of an experimental Moodle 3.11 went fine.

Average of ratings: -
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Ken Task -
Picture of Particularly helpful Moodlers

Your PHP version is?

Please see:

https://www.php.net/manual/en/sodium.installation.php

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks, Ken.

On my VPS, I run PHP v7.4.13.

In my MAMP, I run PHP 7.4.12. This MAMP installation already had sodium enabled and I was successful installing an experimental Moodle 3.11 on it, and also Moodle 4.0. No problems.

On my VPS, the cPanel utility didn't show any way to add sodium. Sodium was not available in the PHP extensions list, which I normally use for all other PHP extensions (like intl.)  I also tried a few PECL utilities, but they didn't work.  What seemed to work were the following commands from Terminal:

yum install libsodium libsodium-devel -y
/opt/cpanel/ea-php74/root/usr/bin/pecl install libsodium

After rebooting the VPS, sodium was installed. I was then able to install experimental copies of Moodle 3.11 and Moodle 4.0.


I forget which URL gave me these directions that worked.

- Login to the server via SSH or Terminal as the root user

- Issue the following command to install the required libraries:

- 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:

- 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:

Reboot the server.


Average of ratings: Useful (2)
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Ken Task -
Picture of Particularly helpful Moodlers

Your experience/method to install due to cPanel.  Might be good for all those using cPanel but maybe not with every provider.

Those not using cPanel/Easy Apache, should be able to use their package manager (apt-get [Ubuntu/Debian],yum [CentOS 7/8 with Remi]) to acquire the necessary libraries and extension.

Kinda surprised one would need to reboot server as normally a restart of Apache web servrice is all that is required for Apache to see the newly installed extensions ... but maybe that's the GoDaddy/CPanel way. smile

Gonna get interesting! :\  ... especially those on shared hosting even if they have ssh to their accounts.

'SoS', Ken

In reply to Ken Task

Re: What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Yes, might have something to do with cPanel, and my specific version of cPanel. Actually, when I searched cPanel's support forums for "install sodium" they directed me to add it via an "Install Manager" tool using PECL, but that didn't work.

Perhaps a restart of Apache web service would have been fine, but it was just as easy for me to do a "graceful reboot" of my VPS.

I am in good shape with sodium on my GoDaddy VPS, although it was a bit more involved than I wanted it to be. This is why I posted. I am trying to anticipate questions from other people who might run into this "sodium" issue, maybe those with a GoDaddy or other company VPS. I also thought it was strange that sodium doesn't show itself in php.ini, as other extensions show.

Yes, you are right Ken. It is "gonna get interesting." I wonder about all those people running hosted servers. Sodium could be another requirement that creates additional problems, which is why I (and probably others) recommend a VPS.
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Ken Task -
Picture of Particularly helpful Moodlers

With cPanel, does Easy Apache (a mis-nomer really as it is related to PHP version and extensions) have a parameter for reading a php.d directory for other extensions to PHP.  Contained in php.d are individual extension ini files and  each .ini file loads the so/extension.

On a CentOS 7 box running remi as repo for PHP, there is a 20-sodium.ini in /etc/php.d/ that loads the sodium extension.   Only reason am sharing that info is a way to disable the loading of an extension on a temp basis.   In that 20--sodium.ini file one could comment out the line by putting a ';' in front of the line that loads.

Which brings me to a suggestion made many moons ago ... Moodle Admins many times are un-aware of checking environment prior to attempting an upgrade ... Notifications screen itself (which many may still get via EMail) ought to have a link in that info that says 'Check Environment'.    Plus, the updating the environment component itself should be done as a part of task/cron job when checking for updates.

Might be the proverbial last nail in the coffin for shared hosting that doesn't load sodium.   Imagine what fun Softac (other) will have supporting that ... uhhhh, they won't, of course, but continue to point to community forums for resolution to issue that their update/upgrade app (available in cPanel) actually created.

Anyhoooooo ...

'SoS', Ken


In reply to Ken Task

Re: What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Yep, Ken. I usually use the cPanel EasyApache4 tool to add PHP extensions to my VPS. And this "sodium" extension is missing (for whatever reason, see screenshot.)  This is how I discovered that sodium seemed to not be a normal PHP extension.

You are correct that many Moodle admins don't do an environment check prior to upgrading, and if sodium is missing, well, "could" clobber their Moodle upgrade. This is why I always try things on an experimental Moodle. I think 3.11 will be released very soon.

On my experimental GoDaddy hosted server, sodium is not installed. Quite honestly, I don't know if I can install it some way. But I don't run Moodle from this hosted server, and who knows what Softac would do.
Attachment No Sodium.png
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Thomas Renard -
Hi Rick,

This was very useful. My 3.11.2 Moodle upgrade worked perfect! Do I have to install this for every php version seperately?

Best regards,

Thomas Renard
Using CENTOS 7.9 - WHM on a 6 cores 16 GB ram Linux VPS server
In reply to Thomas Renard

Re: What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
I am not an expert on sodium and PHP, all that I know is that I installed sodium and it continues to work through all my upgrades of Moodle. I am now at Moodle 3.11.2 (just a little behind the current release.) I have not upgraded my PHP, which I currently have 7.4.13.
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Usman Asar -
Picture of Plugin developers Picture of Testers
sodium are cryptographic libraries in PHP 7.2 onward, for 7.1 and 7.0 one have to install extension. they are used for encryption authentication, storing passwords safely, sharing secret messages, digital signatures. I thought as when I saw it first time required for moodle, some performance related library.
Average of ratings: Useful (2)
In reply to Usman Asar

Re: What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks, Usman. Yes, I saw that sodium has something to do with cryptographic libraries, etc. Apparently, it offers enough features that the Moodle developers saw an advantage to adding it as a requirement for 3.11 and on.
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Alain Raap -
Picture of Particularly helpful Moodlers
Hi Rick,

There was a discussion about Sodium and the fact that it is required as a php extension. This tracker explains some more and we had a challenge to get it working on Redhat: https://tracker.moodle.org/browse/MDL-70363
Sodium will be a required extension in a future LTS version of Moodle. It is possible then to encrypt your Moodle data, there is a new tool in admin cli to generate a sodium key as I described in the tracker MDL-70363.
Average of ratings: Useful (1)
In reply to Alain Raap

Re: What is "sodium," which is a required component for Moodle 3.11?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks Alain. It is good to know that I am not alone being a little troubled by this "sodium" extension. It might challenge some folks, and it may challenge some of us who try to help.
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: What is "sodium," which is a required component for Moodle 3.11?

by Natassia Stelmaszek -
First,

The page reached by the link from the Moodle Environmental check
https://docs.moodle.org/311/en/Environment_-_PHP_extension_sodium
contains a link https://py-ipv8.readthedocs.io/en/latest/preliminaries/install_libsodium/
takes you to a page that says that it doesn't exist yet. (The page, not sodium)



The other link on the page takes you to the PHP.net manual which says that:
A. As of PHP 7.2.0 this extension is bundled with PHP
and also says that for Linux:
B. In order to use this extension you must compile PHP with sodium support by using the --with-sodium[=DIR] configure option

I'm running Moodle on three systems, two CentOS and one Ubuntu using either PHP 7.3 or 7.4 and phpinfo() appears to show it installed and enabled.


and yet the Moodle Server Environment page doesn't seem to recognize it.


Am I looking at the "wrong" sodium?  Do I have to compile a custom version of PHP rather than use the packaged version that comes with the OS?

I think that before the developers "require" sodium, that they need to come up with a way to install it that less technically inclined administrators will be able to use!

Natassia
In reply to Natassia Stelmaszek

Re: What is "sodium," which is a required component for Moodle 3.11?

by Ken Task -
Picture of Particularly helpful Moodlers

On your CentOS 7 box, check to see if lib for sodium is installed:

yum list libsodium

am running PHP 7.3.29 using epel + remi-php73.repo

From code/admin/cli/

php checks.php
OK: All 'status' checks OK

'SoS', Ken