TIPS - How to install cryptography extension libsodium for php7.0.27

How to install cryptography extension libsodium for php7.0.27

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


cd ~/mytempdirectory
wget https://github.com/jedisct1/libsodium-php/archive/2.0.10.zip


4. Unzip the libsodium-php extension archive and go to the resulting directory by typing these commands in your  terminal:


unzip 2.0.10.zip
cd libsodium-php-2.0.10


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:


extension=sodium.so


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.

No thoughts on “TIPS - How to install cryptography extension libsodium for php7.0.27”

Alexandre ELISÉ

Développeur #PHP spécialiste #Joomla! Si mon travail vous a plu n'hésitez pas à laisser votre avis sur Google Reviews. Si mes articles vous ont été utiles vous pouvez me le dire avec Paypal.me ça m'encourage à continuer et me permet de savoir que vous apprecier le contenu. Sinon vous pouvez toujours m'envoyer un email pour me faire part de vos suggestions.

Get the newsletter

Super Joomlers! Get the most out of Joomla!
We hate spam as much as you do and we will not send you email without your prior consent. You can unsubscribe / resubscribe any time you want.