mac 安装php72

  • 更新Homebrew源
brew --repo // 查看Homebrew路径

sudo rm -rf /usr/local/Homebrew/*

git clone git://mirrors.ustc.edu.cn/brew.git /usr/local/Homebrew

mkdir /usr/local/Homebrew/Library/Taps/homebrew

git clone git://mirrors.ustc.edu.cn/homebrew-core.git \
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1
  • 安装php72
brew install [email protected]
sudo ln -s /usr/local/opt/[email protected]/bin/php /usr/local/bin/php
sudo ln -s /usr/local/opt/[email protected]/sbin/php-fpm /usr/local/bin/php

配置文件:
/usr/local/etc/php/7.2/php.ini

检测php配置文件
php --ini

php-fpm启动时指定配置文件
php-fpm -c /path/to/file/php.ini -y /path/to/file/php-fpm.conf

关闭自动重启(保存至其它地方,以防后面想要自启动)
mv ~/Library/LaunchAgents/[email protected] /other/path

  • 安装扩展 redis、mongo、swoole
    方法1 编译安装(需要先解决 phpize 报错)
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include /usr

phpize
./configure --with-php-config=/usr/local/Cellar/[email protected]/7.2.19_1/bin/php-config
make && make install

生成/usr/local/Cellar/[email protected]/7.2.19_1/pecl/20170718/redis.so

vim /usr/local/etc/php/7.2/conf.d/redis.ini 
内容如下:

[redis]
extension=/usr/local/Cellar/[email protected]/7.2.19_1/pecl/20170718/redis.so

; phpredis can be used to store PHP sessions.
; To do this, uncomment and configure below
;session.save_handler = redis
;session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2"

检测扩展模块
php -m | grep redis

方法2 pecl 安装

which pecl // 找到pecl命令所在路径

vim "$(which pecl)"  // 编辑该文件中的php路径 例如:PHP="/usr/local/bin/php"

pecl install swoole

你可能感兴趣的:(mac 安装php72)