After trying to install this extension using pecl without much success,
I had the following message
Warning cannot install module.These settings must match.
To summarize, the pecl extension was not compiled with the right version of php.
The short tutorial I show you here works well and have been tested on
Ubuntu Server 16.04 LTS and php7.0.27.
Please backup all your data before continuing. I will not be responsible for any data loss or problems occuring using this tutorial.
If you are stil reading, lets carry on
1.Type this command in your terminal
sudo apt-get install php7.0-dev libsodium libsodium-dev
2. Create a temporary directory in your home directory by typing the following command in your terminal:
mkdir -p ~/mytempdirectory
3. Go to this new directory you created and download libsodium-php extension by typing these commands in your terminal
4. Unzip the libsodium-php extension archive and go to the resulting directory by typing these commands in your terminal:
5. Once in the libsoium--pho source directory type these command in your terminal to compile the libsodium-php extension with your exact version of php. In my case when I write this tutorial I use PHP 7.0.27
phpize && ./configure && make && sudo make install
6. Now the extension has been compiled and you can add iit to an .ini file. For example /etc/php/7.0/mods-available/sodium.ini and put the following content in the file:
7.Enable the libsodium-php extension with the following command in your terminal:
sudo phpenmod sodium
8. Restart php and/or your web server. (For me it php7.0-fpm) so if you have the same setup type in your terminal:
sudo systemctl reload php7.0-fpm
9. Verify if everything is ok by typing this command in your terminal
php -i | grep -F “sodium”
10. If evrything went right you should see on your screen in your terminal:
sodium support => enabled
That's it for today. See you soon for other cool tips and tricks.