上次升级到10.12,apache配置被重置了,这次依然被重置。系统自带php版本变成了7.1.7,下面是用brew重新安装配置的记录。
#查看php路径
where php
/usr/local/bin/php
/usr/local/bin/php
/usr/bin/php
#查看php版本,注意这两个版本一个是系统自带的,一个是通过brew安装的
/usr/bin/php -v
/usr/local/bin/php
#替换homebrew镜像源
cd /usr/local/Homebrew
git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew.git
brew update
#删除php5.6
brew unlink php56
#添加brew的PHP扩展库
brew tap homebrew/dupes
brew tap homebrew/php
brew update
brew search
brew search php
#安装
brew install homebrew/php/php70
ll /usr/local/Cellar/
#安装php-redis
#https://github.com/phpredis/phpredis#installation-on-osx
brew install php70-redis
#部分提示如下
#/usr/local/etc/php/7.0/conf.d/ext-redis.ini was created,...
#注意这个so文件是系统自带的
/usr/libexec/apache2/libphp7.so
brew reinstall php70 --with-apache
#这里--with-apache被弃用改为--with-httpd
brew reinstall php70 --with-httpd
The php.ini file can be found in:
/usr/local/etc/php/7.0/php.ini
# 修改apache配置文件
sudo vim /private/etc/apache2/httpd.conf
LoadModule php7_module /usr/local/Cellar/php70/7.0.27_19/libexec/apache2/libphp7
.so
#重启
sudo /usr/sbin/apachectl restart
# 测试
php -i
#或者页面通过phpinfo()查看
sudo /usr/sbin/apachectl -t
httpd: Syntax error on line 178 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/Cellar/php70/7.0.27_19/libexec/apache2/libphp7.so into server: dlopen(/usr/local/Cellar/php70/7.0.27_19/libexec/apache2/libphp7.so, 10): Library not loaded: /usr/local/opt/apr-util/libexec/lib/libaprutil-1.0.dylib\n Referenced from: /usr/local/Cellar/php70/7.0.27_19/libexec/apache2/libphp7.so\n Reason: Incompatible library version: libphp7.so requires version 7.0.0 or later, but libaprutil-1.0.dylib provides version 4.0.0
解决
brew reinstall php70 --with-httpd
brew services start php@7.0
sudo pecl install xdebug
发表评论 登录: