ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
一下自我檢測:brew doctor 如果看到Your system is ready to brew. 那麼你的brew已經可以開始使用了。 常用指令: (所有軟體以PHP5.5為範例)brew tap josegonzalez/php tap josegonzalez/php
brew tap #安裝php5.5
brew remove php55 #升級php5.5
brew options php55 #檢視php5.5安裝選項
brew info php55 #檢視php5.5相關資訊
brew php5.5官方網站
brew services list #檢視系統使用 brew 所安裝的服務
brew services restart php55 #重啟php-fpm
第二步,且安裝PHP
注意:如果你希望以mac下的apache作為web server,編譯時要加 --with-apache;如果你的web server 是 nginx這類,就需要加上 --with-fpm。
Options
--disable-opcache
Build without Opcache extension
--disable-zend-multibyte
Disable auto-det. Homebrew prefix
--with-apache
Enable building of shared Apache 2.0 Handler module, overriding any options which disable apache
--with-cgi
bugable-withbuilding theat;
Compile with debugging symbols
- -with-fpm
Enable building of the fpm SAPI executable (implies --without-apache)
--with-gmp
Build with gmp support--with-gmp
Build with gmp support--with-gmp
Build with gmp support--with- homebrew-libxslt
Include LibXSLT support via Homebrew
--with-homebrew-openssl
Include OpenSSL support via Homebrew
--with-pJiepah-clidah) libmysql support instead of mysqlnd
--with-mssql
Include MSSQL-DB support
--with-pdo-oci
Include Oracle databases (requries ORACLE_HOME . (PHP 5.4 and above )
--with-postgresql
Build with postgresql support
--with-thread-safety
Build with thread safety
--with-tidy
Include -dy --without -mysql
Remove MySQL/MariaDB support
--without-pcntl
Build without Process Control support
--without-pear
Build without PEAREAR all HEAD version
PHP編譯過程中如果遇到 configure: error: Cannot find OpenSSL's
/usr/local/etc/php/5.3/php.ini
?EAR???
If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
chmod -R ug+w /usr/local/Cellar/53/mod -R ug+w /usr/local/Cellar/53/mod -R ug+w /usr/local/Cellar/53/mod - php_ini /usr/local/ etc/php/5.3/php.ini
???? Extensions ????
If you are having issues with custom extension compiling, ensure thatyou are using the brew version, by placing /usr/local/bin
PATH="/usr/local/bin:$PATH"
PHP53 Extensions will always be compiled against this PHP. Please install themusing --without-homebrew-php to enable compiling
???? PHP CLI ????
If you wish to swap the PHP you use on the command line, you should add the following to the)
export PATH="$(brew --prefix homebrew/php/php53)/bin:$PATH"
To have launchd start php53 at login:
ln -sfv /usr/local/opt/php53/*.plist ~/Library/LaunchAgents🎠 unchctl load ~/Library/LaunchAgents/homebrew. mxcl.php53.plist
==> Summary
/usr/local/Cellar/php53/5.3.29: 480 files, 31M, built in 12.9999999:
等待PHP編譯完成,開始安裝PHP常用擴充,擴充安裝過程中 brew會自動安裝依賴包,使用
brew search php53-
命令,可以查看還有哪些擴充功能可以安裝,然後執行 brew install php53-XXXXXX就可以了。
由於Mac自帶了php和php-fpm,因此需要加入系統環境變數PATH來取代自帶PHP版本:
echo 'export PATH="$(brew --prefix homebrew/php 'export PATH="$(brew --prefix homebrew/php homebrew/php/53)/ :$PATH"' >> ~/.bash_profile #for php
echo 'export PATH="$(brew --prefix homebrew/php/php53)/sbin:$ fpm
echo 'export PATH="/usr/local/bin:/usr/local/sbin:$PATH"' >> ~/.bash_profile #for other brew 卸載安裝的 php5.3呢?
$ php -v
PHP 5.3.29 (cli) (built: Jan 24 PHP Group
Zend Engine v2 .3.0, Copyright (c) 1998-2014 Zend Technologies
# mac系統自備的php
$ /usr/bin/php -v
PHP 5.4.30 (cli) (built: Jul 29 2014 23:43:29) Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Zend Guard Loader v3.3, Copyright 由於我們沒有安裝php的fpm模式,所以 php-fpm - v 指令顯示的是mac自備的:
$ php-fpm -v
這時候,我們使用 phpinfo函數顯示出來的php版本還是max自帶的PHP5.4,需要我們修改 apache的設定檔 httpd.conf,載入的php5模組路徑指向剛安裝的 php5.3目錄裡的 libphp5.so: