mac 安裝php5.6 降級php

可能失敗的安裝方式

一般的安裝方式是使用如下命令

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

但在國內不好使,唯一還好使用的工具是homebrew

正確的安裝方式

使用如下命令:

brew install [email protected]

安裝後會有以下輸出:

To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php5_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp5.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

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/

[email protected] 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 [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"


To have launchd start exolnet/deprecated/[email protected] now and restart at login:
  brew services start exolnet/deprecated/[email protected]
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Summary
🍺  /usr/local/Cellar/[email protected]/5.6.40: 498 files, 60.5MB

指出了php.ini文件的位置是/usr/local/etc/php/5.6/,非常關鍵,不可以丟失,方便後者由於配置。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章