How to Install PHP Extension -libsodium for Magento 2.4.3 Under Ubuntu 18.0.4?

Sometimes we forgot to install the PHP extension -libsodium, for our new web hosting. When we install Magento 2.4.3, we will get an error message, says the web hosting need libsodium for Magento2.4.3. How to install libsodium then?

For Ubuntu18.0.4, and Ubuntu20.0.4:

cd /usr/src/
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz
tar -zxvf libsodium-1.0.18.tar.gz
cd libsodium*

./configure
make && make check
make install

pecl install libsodium

Whe we have installed libsodium successfully under Ubuntu, we will get the following message:

Build process completed successfully
Installing ‘/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/sodium.so’
install ok: channel://pecl.php.net/libsodium-2.0.23
Extension libsodium enabled in php.ini

Note: Do not disable exec, popen, which are within php.ini. Otherwise You will be failed to install libsodium. After you have installed successfully, you can redisable exec, popen for your web hosting security!

 

CentoOS 7:

 

yum install libsodium-devel
pecl install -f libsodium

Build process completed successfully
Installing ‘/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/sodium.so’
install ok: channel://pecl.php.net/libsodium-2.0.23
Extension libsodium enabled in php.ini