Brew is the package management tool under Mac, which allows you to easily install development tools by Github managed for a MAC-compatible compilation configuration and Patch. The MAC is easy to install with Ruby, and it automatically installs git for you as well. Official website: http://brew.sh
Installation method:
Ruby-e "$ (curl-fssl https://raw.github.com/Homebrew/homebrew/go/install)"
Use the following methods to see whether brew was installed successfully and the current version:
liondemacbook-pro:~ lion$ brew-v
Homebrew 0.9.5
Add Brew's PHP extension library:
liondemacbook-pro:~ lion$ Brew Update
liondemacbook-pro:~ lion$ brew tap homebrew/dupes
liondemacbook-pro:~ lion$ Brew tap homebrew/php
liondemacbook-pro:~ lion$ Brew Tap josegonzalez/homebrew-php
You can use the Brew options php55 command to see what options you can have when installing, because I have previously installed curl, LIBXSLT, OpenSSL, so in the options, I am prompted to use the associated Extensions for brew installation:
Liondemacbook-pro:library lion$ Brew Options Php55--disable-opcache build without Opcache extension--disable-zend-mul Tibyte Disable auto-detection of Unicode encoded scripts (PHP 5.2 and 5.3 only)--homebrew-apxs builds against APXS in Homebrew prefix--with-apache Enable building of Shared Apache 2.0 Handler module, overriding any options which disable Apache--with-cgi Enable Building of the CGI executable (implies--without-apache)--with-debug Compile with debugging Symbols--WITH-FPM Enable Building of the FPM SAPI executable (implies--without-apache)--with-gmp build with GMP Su Pport--with-homebrew-curl include curl support via homebrew--with-homebrew-libxslt include LIBXSLT support via HOMEB Rew--with-homebrew-openssl include OpenSSL support via homebrew--with-imap Include IMAP extension--WITH-INTL
Ude Internationalization Support--with-libmysql Include (Old-style) libmysql support instead of MYSQLND--with-mssql Include mssql-db Support
--with-pdo-oci include Oracle databases (requries oracle_home be set)--with-pgsql include PostgreSQL support--with-
phpdbg Enable Building of the phpdbg SAPI executable (PHP 5.4 and above)--with-thread-safety build with thread safety --with-tidy Include Tidy support--without-bz2 build without bz2 support--without-mysql Remove mysql/mariadb RT--without-pcntl Build without Process control support--without-pear builds without pear--head install head versi
On
Start installation of PHP5.5.15, Php-fpm.ini and php.ini after installation in directory:/USR/LOCAL/ETC/PHP/5.5/below
Liondemacbook-pro:library lion$ Brew Install php55--with-mssql--with-homebrew-openssl- With-homebrew-curl--with-fpm--with-debug--with-gmp--with-imap--with-tidy--with-libmysql ==> Installing Dependencies for Php55:curl, FreeTDS, GMP ==> installing php55 dependency:curl ==> downloading HTTPS://DOWNLOADS.S F.net/project/machomebrew/bottles/curl-7.37.1.mavericks.bottle.tar.gz ######################################### ############################### 100.0% ==> Pouring curl-7.37.1.mavericks.bottle.tar.gz ==> Caveats this formula
is keg-only, which means it being not symlinked into/usr/local.
Mac OS X already provides this software and installing another version in parallel can cause all kinds of trouble. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build Variables:ldflags:-l/u
Sr/local/opt/curl/lib Cppflags:-i/usr/local/opt/curl/include
==> summary/usr/local/cellar/curl/7.37.1:285 files, 2.8M ==> installing Php55 dependency:freetds ==> Downloa Ding http://mirrors.ibiblio.org/freetds/stable/freetds-0.91.tar.gz ############################################# ########################### 100.0% ==>./configure--prefix=/usr/local/cellar/freetds/0.91--with-openssl=/usr/ Local/opt/openssl--with-tdsver=7.1--mandir=/usr ==> make ==> make install/usr/local/cellar/freetds/0.91:600 fi Les, 9.9M, built in 2.2 minutes ==> installing PHP55 dependency:gmp ==>-Downloading Https://downloads.sf.net/projec T/machomebrew/bottles/gmp-6.0.0a.mavericks.bottle.tar.gz ###################################################### ################## 100.0% ==> pouring gmp-6.0.0a.mavericks.bottle.tar.gz/usr/local/cellar/gmp/6.0.0a:15 files, 3.2M ==> Installing php55 ==> downloading Http://www.php.net/get/php-5.5.15.tar.bz2/from/this/mirror already Downloaded:/library/caches/homebrew/php55-5.5.15 ==>./configuRe--prefix=/usr/local/cellar/php55/5.5.15--localstatedir=/usr/local/var--sysconfdir=/usr/local/etc/php/5.5--= = > Make ==> make install ==>/usr/local/cellar/php55/5.5.15/bin/pear config-set php_ini/usr/local/etc/php/5.5/ PHP.ini ==> Caveats The php.ini file can be found in:/usr/local/etc/php/5.5/php.ini✩✩✩✩pear✩✩✩✩if PEAR compl Ains about permissions, ' fix ' The default PEAR permissions and Config:chmod-r ug+w/usr/local/cellar/php55/5.5.15/lib/ PHP pear Config-set php_ini/usr/local/etc/php/5.5/php.ini✩✩✩✩extensions✩✩✩✩if You are have issues with custom
Extension compiling, ensure that you are using the brew version, by Placing/usr/local/bin Before/usr/sbin in your PATH: Path= "/usr/local/bin: $PATH" PHP55 Extensions'll always be compiled to against this PHP.
Please install them the using--without-homebrew-php to enable compiling against system PHP. ✩✩✩✩php cli✩✩✩✩if you are wish to swap the PHP with the command line, you should addThe following to ~/.BASHRC, ~/.ZSHRC, ~/.profile or your shell ' s equivalent configuration-File:export ' $ (brew-
-prefix homebrew/php/php55)/bin: $PATH "✩✩✩✩fpm✩✩✩✩to launch PHP-FPM on startup: * If It is your A: Mkdir-p ~/library/launchagents cp/usr/local/cellar/php55/5.5.15/homebrew.mxcl.php55.plist ~/Library/LaunchAgents /Launchctl load-w ~/library/launchagents/homebrew.mxcl.php55.plist * If This is a upgrade and you already have The homebrew.mxcl.php55.plist loaded:launchctl unload-w ~/library/launchagents/homebrew.mxcl.php55.plist cp/usr /local/cellar/php55/5.5.15/homebrew.mxcl.php55.plist ~/library/launchagents/launchctl load-w ~/Library/
Launchagents/homebrew.mxcl.php55.plist the control script is located at/usr/local/cellar/php55/5.5.15/sbin/php55-fpm Mountain Lion comes with php-fpm pre-installed, to ensure your are using the brew version you need to make sure/usr/local /sbin is before/usr/sbin in your PATH: Path= "/usr/local/sbin: $PATH" You may also need to edit the plist to use the correct "UserName".
Please note that the plist is called ' homebrew-php.josegonzalez.php55.plist ' versions of this formula. To have launchd start php55 in login:ln-sfv/usr/local/opt/php55/*.plist ~/library/launchagents Then to load Php55 : Launchctl load ~/library/launchagents/homebrew.mxcl.php55.plist ==> summary/usr/local/cellar/php55/5.5.15:477 F
Iles, 43M, built in 3.9 minutes
If an error such as Configure:error:Cannot find OpenSSL ' s <evp.h> appears in the process, execute the following command to update the Xcode:
In the PHP5 installation completion prompts, how to do the PHP5 and Mac from the PHP and PHP-FPM replacement, after executing the following command, we can see that the current version of PHP is already up to date:
liondemacbook-pro:~ lion$ Echo ' export path=/usr/local/bin: $PATH ' >> ~/.bash_profile
liondemacbook-pro:~ lion$ Echo ' export path=/usr/sbin: $PATH ' >> ~/.bash_profile
liondemacbook-pro:~ lion$ echo ' Export path=/usr/ Local/sbin: $PATH ' >> ~/.bash_profile
liondemacbook-pro:~ lion$ source ~/.bash_profile
liondemacbook-pro:~ lion$ php-v
php 5.5.15 (CLI) (Built:aug 2014 15:37:16) (DEBUG)
Copyright (c) 1997-2014 Th E PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies liondemacbook-pro:~ lion$
Using the Brew Search php55-command, you can see what additional extensions can be installed, and then execute the brew install PHP55-XXX.
liondemacbook-pro:~ lion$ Brew Search PHP55-PHP55-AMQP php55-igbinary php55-msgpack php55-runkit Php55-varn Ish PHP55-APCU php55-imagick php55-mysqlnd_ms php55-scrypt php55-vld php55-augmentedtypes php55-inclued p Hp55-oauth php55-snappy php55-wbxml php55-binpack php55-intl php55-opcache PHP55-SOLR php55-xcache p Hp55-blitz php55-ioncubeloader php55-parsekit php55-sphinx php55-xdebug php55-boxwood php55-jsmin php55- Pcntl php55-spl-types Php55-xhgui php55-chdb php55-judy php55-pdflib php55-ssh2 php55-xhp Php55-couch Base php55-leveldb php55-pdo-dblib php55-stats php55-xhprof php55-crypto php55-libevent php55-pdo-pgsql Php55-stemmer php55-xmldiff php55-dbase php55-libvirt php55-phalcon php55-sundown Php55-yac Php55-dbus Php55-lz4 php55-proctitle php55-svm php55-yaf php55-dmtx php55-lzf php55-propro php55-swoole php55 -yaml Php55-ev Php55-mailparse php55-protobuf php55-thrift Php55-yar php55-gearman php55-mcrypt Php55-pspell php55-tidy Php55-yaz Php55-geoip php55-memcache php55-pthreads php55-timezonedb php55-yp php55-gmagick Php55-memcache D PHP55-RAPHF php55-tokyotyrant Php55-yrmcds php55-graphdat php55-midgard2 Php55-redis PHP55-ZMQ php55-htscanner Php55-mongo php55-redland php55-uploadprogress php55-zookeeper php55-http Php55-mo
Squitto Php55-riak Php55-uuid
I installed the following php5.5 several extensions:
liondemacbook-pro:~ lion$ Brew Install Php55-imagick php55-igbinary Php55-ev php55-gmagick Php55-geoip Php55-memcache php55-memcached Php55-thrift Php55-xdebug Php55-sphinx composer
Next we test the PHP-FPM configuration correctly and start correctly:
#测试php-fpm configuration is correct liondemacbook-pro:bin lion$ php-fpm-t [14-aug-2014 16:14:30] Notice:configuration file/usr/local/etc /php/5.5/php-fpm.conf test is successful liondemacbook-pro:bin lion$ php-fpm-c/usr/local/etc/php/5.5/php.ini-y/usr/ local/etc/php/5.5/php-fpm.conf-t [14-aug-2014 16:14:48] Notice:configuration file/usr/local/etc/php/5.5/ Php-fpm.conf test is successful #启动php-fpm liondemacbook-pro:bin lion$ launchctl load-w ~/library/launchagents/homebrew . mxcl.php55.plist #查看9000端口是否在运行 liondemacbook-pro:bin lion$ lsof-i:9000 COMMAND PID USER FD TYPE DEVICE size/ Off NODE NAME php-fpm 51241 Lion 8u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) php-fpm 51243 Lion 0 U IPv4 0xce9d0f6417637937 0t0 tcp Localhost:cslistener (LISTEN) php-fpm 51244-Lion 0u IPv4 0xce9d0f6417637937 0t0 TCP Localhost:cslistener (LISTEN) php-fpm 51245 Lion 0u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) #关 Shut down the PHP-FPM process, then look at Port 9000, not listening liondemacbook-pRo:bin lion$ PS aux|grep php-fpm|grep-v ' grep ' |awk ' {print $} ' |xargs kill-9 liondemacbook-pro:bin lion$ lsof-i:9000 li
Ondemacbook-pro:bin lion$
Set the PHP-FPM to run (in fact, in the installation completed prompts, also have instructions):
Ln-sfv/usr/local/opt/php55/*.plist ~/library/launchagents
launchctl load ~/library/launchagents/ Homebrew.mxcl.php55.plist