Amplifier
Amplifier

Reputation: 203

Sodium is not loading on XAMPP PHP 7.2

Hey for some reason when i use XAMPP PHP 7.2, all of the sodium functions are not working. When i run print_r(get_loaded_extensions()); it does not show sodium on the list. When i go to http://php.net/manual/en/sodium.installation.php it says no installation needed they are a part of the core. So i went to my php.ini configuration file and made sure that it did not disable sodium, it says extension=php_sodium.dll. I went to the console to double check to see if their were any errors, there was none. It was weird because Argon2i is working fine. The Argon2i constants are all defined and when used in the password_hash() function it generates a password hash no problem. I am using windows as my OS. Is there anything else that can cause something like this, any help would be nice. Thanks in advance.

Upvotes: 17

Views: 56240

Answers (8)

Kifah Al-humaidey
Kifah Al-humaidey

Reputation: 21

this error could be raised by "httpd" on windows xampp because libsodium.dll is not loaded. however, you can solve it by adding the path of the DLL file to :

"C:\xampp\apache\conf\extra\httpd-xampp.conf"

then add the line

loadFile "C:/xampp/php/libsodium.dll"

solving libsodium.dll is not found or loaded

finally restart your apache server, and you will be ok

Upvotes: 2

Kapil Dev Singh
Kapil Dev Singh

Reputation: 151

This answer is only for Linux(Ubuntu) users

There is default PHP installed as a system package but if you are using self contained installation of PHP (XAMPP [Binami]) then you have to provide php-config path in following attribute of ./configure command while installing the LIBSODIUM for your PHP.

--with-php-config

I have installed xampp-linux-x64-7.4.15-0 and surprisingly there is no sodium PHP module in this setup. I installed Sodium library first and then install PHP Libsodium extesnion for XAMPP.

/opt/lampp/etc/php -m    //Check if you have sodium installed 

sudo apt-get update
sudo apt-get install build-essential libtool autoconf 

Download stable version of Sodium Library by following link

https://doc.libsodium.org/

//Go inside the package folder

cd <downloaded package dir>

./configure 
make
sudo make install

It will install library and you can check inside the /usr/local/lib/. The file for libsodium has been created with so extension.

Now we will download and install PHP library for

https://github.com/jedisct1/libsodium-php

//Go inside the package folder

cd <downloaded package dir>

./configure --with-php-config=/opt/lampp/bin/php-config   //This time we provided preferred php config
make
sudo make install

This will isntall extension for XAMPP PHP and you can check sodium.so file has been created inside /opt/lampp7.4/lib/php/extensions/no-debug-non-zts-2019****.

Add extension inside php.ini

sudo bash -c 'echo "extension="sodium.so"" >> /opt/lampp/etc/php.ini'

Restart XAMPP and check installed php modules

sudo /opt/lampp/lampp restart

/opt/lampp/etc/php -m 

If all works fine then you will find sodium in list defiantly.

CHEERS

Upvotes: 3

Mudassir
Mudassir

Reputation: 408

This will work for wamp also

check-in PHP module if sodium is available or not with the following command

cmd> php -m
cmd> php --ri sodium

if sodium is not listed then go to your /php/php.ini and search for ';extension=sodium' and remove ';' you will be good to go

Upvotes: 5

absentx
absentx

Reputation: 1427

For anyone struggling with this in Windows XAMPP including PHP 7.3.9:

There is already a libsodium.dll file in c:\xampp\xampp\php.

However, the extension is not activated by default in the php.ini file. Simply edit the file as @Alshoja indicated. In fact, the needed entry is already there but commented out, simply remove the comment:

#extension=sodium;

to

extension=sodium;

Restart the server, then verify through phpinfo(); and searching for "sodium" you should now see a "sodium support" column with associated information.

Upvotes: 4

Alshoja
Alshoja

Reputation: 527

Open php.ini file from C:\xampp\php\ -> under Dynamic Extensions and add

extension=sodium

Upvotes: 12

Thomas Wickert
Thomas Wickert

Reputation: 321

For Windows XAMPP PHP 7.2.4, to correct the Error:

PHP Warning: PHP Startup: Unable to load dynamic library 'sodium' (tried: C:\xampp\php\ext\sodium (The specified module could not be found.), C:\xampp\php\ext\php_sodium.dll (The specified module could not be found.)) in Unknown on line 0

There must be a copy of php/libsodium.dll (PHP Extension) in apache/bin/ (Apache Module). It is assumed, but not tested, that it must be same file.

Assuming that php/libsodium.dll and php/ext/php_sodium.dll are the same build, which is the case with a new install of XAMPP 7.2.4, the install is:

1. Add "extension=sodium" to php.ini (no quotes)
2. Copy php/libsodium.dll to apache/bin/
3. Restart Server

Upvotes: 32

jim60105
jim60105

Reputation: 86

I encountered the same problem, but reinstall XAMPP 7.2 doesn't help.
Finally, I returned to XAMPP 7.1.14 then installed sodium additionally, and it works.

  1. Install XAMPP(xampp-win32-7.1.14-0-VC14)
  2. Download libsodium named php_libsodium-2.0.9-7.1-ts-vc14-x86.zip
  3. Rename php_sodium.dll to php_libsodium.dll, then put it into C:\xampp\php\ext
  4. Put libsodium.dll into C:\xampp\apache\bin
  5. Add into php.ini: extension=php_libsodium.dll

I know rollback is not a good idea.
But at least it works for me.

Upvotes: 5

Jean-Francois Rondeau
Jean-Francois Rondeau

Reputation: 1408

Are you sure that you edit the correct php.ini?

Starting with PHP 7.2, ini file (at least on my Windows PC), the syntax to load extension is now extension=modulename instead of extension=php_modulename.dll.

Upvotes: 5

Related Questions