安装 MongoDB 和 memcached 等扩展
Mac 下 homebrew 更新后不支持直接安装,所以都需要从 pecl 安装,特此记录一下
1.安装pecl install memcached 时候报错
需要先安装
brew install libmemcached
brew install pkg-config
2.php-memcached安装
wget https://pecl.php.net/get/memcached-3.1.5.tgz
sudo tar zxvf memcached-3.1.5.tgz
cd memcached-3.1.5
sudo phpize
which php-config
sudo ./configure --with-php-config=/usr/local/Cellar/php@7.1/7.1.17/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
sudo make
sudo make install
vim /usr/local/etc/php/7.1/php.ini
php -m | grep memcache
brew services restart php@7.1
image.png完成后看下
MongoDB 扩展版本低
composer require phpmailer/phpmailer
因为phpmailer 不能安装,提示 mongodb 扩展版本过低
wget https://pecl.php.net/get/mongodb-1.9.0.tgz
下来好后解压(版本我选 1.5.5的)
tar -zxvf /Users/sunjianjun/Downloads/mongodb-1.5.5.tgz
cd mongodb-1.5.5
phpize
sudo ./configure
make && make install
php -i | grep extension_dir
cd /usr/local/Cellar/php@7.1/7.1.32_1/lib/php/20160303/
复制 so 文件到 extnsiong_dir目录下
cp mongodb.so /usr/local/Cellar/php@7.1/7.1.32_1/lib/php/20160303/
到 php.ini下增加配置
cd usr/local/etc/php/
vim php.ini 增加 mongodb
php -i | grep extension_dir
重启 php-fpm 查看是否成功
sudo lsof -i:9000
sudo killall php-fpm
php-fpm --daemonize
ps aux |grep php-f
安装 redis 扩展
- 下载 wget https://pecl.php.net/get/redis-5.3.3.tgz
image.png
tar -zxvf redis-5.3.3.tgz
cd redis-5.3.3
phpize
./configure
>报错
checking for hash includes... configure: error: Cannot find php_hash.h
>原因是没有找到对应的 php7.4版本的 php.ini
./configure --with-php-config=/usr/local/Cellar/php@7.4/7.4.14_1/bin/php-config --enable-redis-igbinary=no --enable-redis-lzf=no --enable-redis-zstd=no
make && make install
vim /usr/local/etc/php/7.4/php.ini
>新增一条
extension=redis.so
>重启 php-fpm
ps aux | grep php-fpm | grep -v grep | awk '{print $2}' | xargs kill
php -m |grep redis #查看是否存在扩展
image.png
image.pngphpinfo查看
网友评论