可能失敗的安裝方式
一般的安裝方式是使用如下命令
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/
,非常關鍵,不可以丟失,方便後者由於配置。