Laravel Homestead 安装 Redis 扩展
Homested php extionsion shell for redis
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
cd /home/vagrant
if [ ! -d "redis-4.1.1.tgz"]; then
wget https://pecl.php.net/get/redis-4.1.1.tgz
tar -zxf redis-4.1.1.tgz
fi
cd redis-4.1.1
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php5.6-dev
phpize5.6
./configure --with-php-config=/usr/bin/php-config5.6 > /dev/null
make clean > /dev/null
make >/dev/null 2>&1
sudo make install
sudo chmod 644 /usr/lib/php/20131226/redis.so
sudo bash -c "echo 'extension=redis.so' > /etc/php/5.6/mods-available/redis.ini"
sudo rm -rf /etc/php/5.6/cli/conf.d/20-redis.ini /etc/php/5.6/fpm/conf.d/20-redis.ini
sudo ln -s /etc/php/5.6/mods-available/redis.ini /etc/php/5.6/cli/conf.d/20-redis.ini
sudo ln -s /etc/php/5.6/mods-available/redis.ini /etc/php/5.6/fpm/conf.d/20-redis.ini
sudo service php5.6-fpm restart
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.0-dev
phpize7.0
./configure --with-php-config=/usr/bin/php-config7.0 > /dev/null
make clean > /dev/null
make >/dev/null 2>&1
sudo make install
sudo chmod 644 /usr/lib/php/20151012/redis.so
sudo bash -c "echo 'extension=redis.so' > /etc/php/7.0/mods-available/redis.ini"
sudo rm -rf /etc/php/7.0/cli/conf.d/20-redis.ini /etc/php/7.0/fpm/conf.d/20-redis.ini
sudo ln -s /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/cli/conf.d/20-redis.ini
sudo ln -s /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/fpm/conf.d/20-redis.ini
sudo service php7.0-fpm restart
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php7.1-dev
phpize7.1
./configure --with-php-config=/usr/bin/php-config7.1 > /dev/null
make clean > /dev/null
make >/dev/null 2>&1
sudo make install
sudo chmod 644 /usr/lib/php/20160303/redis.so
sudo bash -c "echo 'extension=redis.so' > /etc/php/7.1/mods-available/redis.ini"
sudo rm -rf /etc/php/7.1/cli/conf.d/20-redis.ini /etc/php/7.1/fpm/conf.d/20-redis.ini
sudo ln -s /etc/php/7.1/mods-available/redis.ini /etc/php/7.1/cli/conf.d/20-redis.ini
sudo ln -s /etc/php/7.1/mods-available/redis.ini /etc/php/7.1/fpm/conf.d/20-redis.ini
sudo service php7.1-fpm restart
phpize7.2
./configure --with-php-config=/usr/bin/php-config7.2 > /dev/null
make clean > /dev/null
make >/dev/null 2>&1
sudo make install
sudo chmod 644 /usr/lib/php/20160303/redis.so
sudo bash -c "echo 'extension=redis.so' > /etc/php/7.2/mods-available/redis.ini"
sudo rm -rf /etc/php/7.2/cli/conf.d/20-redis.ini /etc/php/7.2/fpm/conf.d/20-redis.ini
sudo ln -s /etc/php/7.2/mods-available/redis.ini /etc/php/7.2/cli/conf.d/20-redis.ini
sudo ln -s /etc/php/7.2/mods-available/redis.ini /etc/php/7.2/fpm/conf.d/20-redis.ini
sudo service php7.2-fpm restart
phpize7.3
./configure --with-php-config=/usr/bin/php-config7.3 > /dev/null
make clean > /dev/null
make >/dev/null 2>&1
sudo make install
sudo chmod 644 /usr/lib/php/20160303/redis.so
sudo bash -c "echo 'extension=redis.so' > /etc/php/7.3/mods-available/redis.ini"
sudo rm -rf /etc/php/7.3/cli/conf.d/20-redis.ini /etc/php/7.3/fpm/conf.d/20-redis.ini
sudo ln -s /etc/php/7.3/mods-available/redis.ini /etc/php/7.3/cli/conf.d/20-redis.ini
sudo ln -s /etc/php/7.3/mods-available/redis.ini /etc/php/7.3/fpm/conf.d/20-redis.ini
sudo service php7.3-fpm restart
- 复制 shell 保存到
/vagrant/home/
目录 比方说命名为 redis_install.sh
- 给予执行权限
sudo chmod +x redis_install.sh
- 执行
./redis_install.sh
-
php[版本] -m | grep redis
验证
3 Comments
如果想在本地链接 Homestead 的redis ,请修改redis 配置文件的 bind 属性,
生成不了redis.so Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20170718/redis.so (/usr/lib/php/20170718/redis.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/redis.so.so (/usr/lib/php/20170718/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
homestead version?