I can not disable it since on the same server another symfony application is running which require sodium. Please suggest
Sodium extension error with PHP 8.1
Hello I upgraded my server with PHP 8.1 with Laravel 10 . I am getting below PHP warning with Laravel php artisan
PHP Warning: Module "sodium" is already loaded in Unknown on line 0
Looks like you have multiple declarations of this extension
extension=sodium.so
extension=sodium.so
somewhere is declared twice or more, check you ini files
It seems like the sodium extension is being loaded twice, which is causing the warning message you're seeing. This can happen if the extension is loaded both as a compiled module and through the php.ini configuration file. Here's how you can resolve this issue:
-
Check Your
php.iniFile(s): Locate yourphp.inifile(s) used by the CLI (Command Line Interface). You can find out whichphp.inifile is being used by running the following command:php --iniThis will list all the configuration files used by PHP. Open the
php.inifile and look for the line that loads thesodiumextension. It might look something like this:extension=sodiumIf you find such a line, comment it out by adding a semicolon (
;) at the beginning of the line:;extension=sodiumSave the file and try running
php artisanagain to see if the warning persists. -
Check for Additional Configuration Files: PHP can also load additional
.inifiles from a separate directory, which is often listed in the output ofphp --iniunder "Scan for additional .ini files in:". Check this directory for any.inifiles that might be loading thesodiumextension and comment out the relevant lines as described above. -
Recompile PHP (if applicable): If you have compiled PHP from source and included the
sodiumextension, make sure you haven't also tried to load it viaphp.ini. If you have, you'll need to remove theextension=sodiumline from yourphp.inifile. -
Restart Your Web Server: After making changes to your
php.inifile(s), you may need to restart your web server for the changes to take effect. Use the appropriate command for your web server to restart it.For Apache, it might be something like:
sudo service apache2 restartFor Nginx, it might be:
sudo service nginx restartFor PHP's built-in server (if you're using it for some reason):
php artisan serve
After following these steps, the warning about the sodium extension being already loaded should be resolved. If the issue persists, ensure that you're editing the correct php.ini file(s) for the PHP CLI and not just the one used by your web server.
Please or to participate in this conversation.