ubuntu22.04安装redis
第一步,安装redis-server
apt install redis-server
systemctl start redis-server
systemctl status redis-server
redis-cli
第二步,编译php,加在redis扩展
# 安装编译依赖(针对手动编译的PHP7.4)
sudo apt update && sudo apt install -y gcc make libc6-dev redis-server libredis-dev autoconf automake libtool
或
sudo apt update && sudo apt install -y gcc make libc6-dev redis-server libhiredis-dev autoconf automake libtool
# 确认phpize(PHP扩展编译工具)是你手动编译的PHP7.4版本
/usr/local/php/bin/phpize -v
# 输出应该包含「PHP Api Version: 20190902」(对应PHP7.4),而非8.1
wget https://pecl.php.net/get/redis-5.3.7.tgz
tar -zxvf redis-5.3.7.tgz
cd redis-5.3.7
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && sudo make install
# 安装成功后,会输出类似:
# Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
# 这说明redis.so已经正确生成到目标目录
vi /usr/local/php/etc/php.ini
extension=redis.so
重启PHP
浙公网安备 33010602011771号