1,安装 homebrew
2,安装 PHP 7.2,autoconf,openssl,redis
brew install php@7.2
brew install autoconf
brew install openssl
brew install redis
3,下载 hiredis,解压后进入相应目录
make && make install
4,下载 swoole,解压后进入相应目录
/usr/local/Cellar/php@7.2/7.2.16/bin/phpize
./configure --with-php-config=/usr/local/Cellar/php@7.2/7.2.16/bin/php-config --enable-mysqlnd --enable-openssl --with-openssl-dir=/usr/local/opt/openssl
make && make install
cd /usr/local/etc/php/7.2
vim php.ini
5,在php.ini 文件中添加:extension=swoole
6,调整php版本
vim ~/.bash_profile
添加:export PATH=/usr/local/Cellar/php@7.2/7.2.16/bin:$PATH
source ~/.bash_profile
7,验证
php -m
或者
php --ri swoole