mac php 安裝php多版本

以前的開發,PHP的版本都是基於php7.3 。but!!!php

接到一個老項目 tp3.1的。無法用php7.3 只能在裝一個php5.6了。真坑爹。爲啥還要TP3.1的項目。而且是剛開發的新項目。html

真的很無語。。vim

MacOS Mojave 系統以後,若是想安裝 php5.6 版本的時候,沒法用brew install php5.6 安裝,由於在新的 brew 中已經廢棄了 php5.6 ,若是使用 brew search php 搜索出來的Php版本最低是 php@7.1 的,因此有相關需求的能夠按照下面方法安裝bash

添加源
1
brew tap exolnet/homebrew-deprecated
搜索PHP
1
brew search phpphp7

2 選擇app

brew install exolnet/deprecated/php@5.6php-fpm

安裝完後會提示以下信息:this

==> 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"rest

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-fpmorm

 

注意點

1 須要把php7.3的環境變量註釋

2 brew 停調php7.3

3 brew 開啓php5.6 

 

 換成了php5.6  😐

----------------------------------

1 brew services stop php@5.6

2 vim .zshrc 開啓要運行php版本的環境變量 =>php@7.2

3  source .zshrc

4 brew services start php@7.2

相關文章
相關標籤/搜索