下载编译安装libsodium
- wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
- tar -zxf libsodium-1.0.18-stable.tar.gz
- cd libsodium-stable
- ./configure --without-libsodium
- make && make check
- sudo make install
下载编译安装sodium
- yum install autoconf
- wget https://www.php.net/distributions/php-7.4.21.tar.gz
- tar xf php-7.4.21.tar.gz
- cd php-7.4.21/ext/sodium
核对导入/usr/lib/pkgconfig路径
- export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- echo $PKG_CONFIG_PATH
安装扩展
- /usr/local/php/bin/phpize
- ./configure --with-php-config=/usr/local/php/bin/php-config
- make && make install
安装成功
修改php.ini添加扩展
- extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902"
- extension=sodium.so
重启php-fpm
systemctl restart php-fpm
查看是否安装成功
php -m | grep sod
安装过程中如果出现
configure: error: Package requirements (libsodium >= 1.0.8) were not met: No package 'libsodium' found
这样的问题需要确认 安装libsodium时是否执行了 ./configure --without-libsodium
参考链接:configure: error: Package requirements (libsodium) were not met: No package 'libsodium' found-CSDN博客