mac php 安装php多版本
作者:互联网
之前的开发,PHP的版本都是基于php7.3 。but!!!
接到一个老项目 tp3.1的。没法用php7.0 只能在装一个php5.6了。真坑底。为啥还要TP3.1的项目。并且是刚开发的新项目。
真的很无语。。
MacOS Mojave 系统之后,如果想安装 php5.6 版本的时候,无法用brew install php5.6 安装,因为在新的 brew 中已经废弃了 php5.6 和 php7.0,如果使用 brew search php 搜索出来的Php版本最低是 php@7.1 的,所以有相关需求的可以按照下面方法安装
添加源
1
brew tap exolnet/homebrew-deprecated
搜索PHP
1
brew search php
2 选择
brew install exolnet/deprecated/php@5.6
安装完后会提示如下信息:
==> php@5.6
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/5.6/
php@5.6 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have php@5.6 first in your PATH run:
echo 'export PATH="/usr/local/opt/php@5.6/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@5.6/sbin:$PATH"' >> ~/.bash_profile
For compilers to find php@5.6 you may need to set:
export LDFLAGS="-L/usr/local/opt/php@5.6/lib"
export CPPFLAGS="-I/usr/local/opt/php@5.6/include"
To have launchd start exolnet/deprecated/php@5.6 now and restart at login:
brew services start exolnet/deprecated/php@5.6
Or, if you don't want/need a background service you can just run:
sudo php-fpm
注意点
1 需要把php7.3的环境变量注释
2 brew 停调php7.3
3 brew 开启php5.6
换成了php5.6
标签:php5.6,5.6,mac,usr,版本,brew,php,local 来源: https://www.cnblogs.com/guoshuai-yangxu/p/11647024.html