Mac入門--如何使用brew安裝多個PHP版本


一 安裝7.1

1. 安裝PHP7.1

brew install php@7.1

2. 修改配置 php-fpm.conf,一般在/usr/local/etc/php下(如果php-fpm.conf中不存在,則查找php-fpm.d目錄)

vim php-fpm.conf

listen = 127.0.0.1:9000

3. 啟動PHP7.1

brew services start php@7.1

4. 這時php-fpm會監聽9000端口,修改nginx的配置文件改為端口為9000(一般在/usr/local/etc/nginx/下面)

vim nginx.conf

fastcgi_pass   127.0.0.1:9000

5. 啟動nginx服務

#啟動 brew services start nginx

#重啟 brew services restart nginx

6. 查看當前版本

php -v

 

二 安裝並切換7.2

1. 清除PHP7.1的軟鏈

brew unlink php@7.1

2. 安裝PHP7.2 

brew install php@7.2

3. 添加PHP7.2的軟鏈

brew link php@7.2

4. 修改配置 php-fpm.conf

vim php-fpm.conf

listen = 127.0.0.1:9001

5. 啟動PHP7.2

brew services start php@7.2

6. 修改nginx配置

vim nginx.conf

fastcgi_pass   127.0.0.1:9001

7. 重啟nginx服務

brew services restart nginx

8. 查看當前版本

php -v 

9.修改環境變量

vi ~/.bash_profile

10.重新刷新環境變量

source ~/.bash_profile 

 

以上就是這次的全部內容 !

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM