Use Brew to install php5.5.15_php instances in a Mac environment

Source: Internet
Author: User
Tags geoip gmp imap intl php cli sapi tidy
Brew is the package management tool under Mac, and it's easy to install development tools by using Github to host your Mac-friendly compilation configuration and patches. Mac comes with Ruby so it's easy to install, and it automatically installs git 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 if the brew was successfully installed, as well as the current version:

liondemacbook-pro:~ lion$ brew-vhomebrew 0.9.5

Add a brew PHP extension library:

liondemacbook-pro:~ lion$ Brew updateliondemacbook-pro:~ lion$ Brew tap homebrew/dupesliondemacbook-pro:~ lion$ Brew Tap homebrew/phpliondemacbook-pro:~ lion$ Brew Tap josegonzalez/homebrew-php


You can use the Brew options php55 command to see what options are available for installation, because I have previously installed curl, libxslt, and OpenSSL so that you will be prompted in the options to use the associated extensions for the brew installation:

Liondemacbook-pro:library lion$ Brew Options Php55--disable-opcache Build without Opcache   Extension--disable-zend-multibyte Disable auto-detection of Unicode encoded scripts (PHP 5.2 and 5.3 only)--homebrew-apxs Build against Apxs in Homebrew Prefix--with-apache Enable building of GKFX Apache 2.0 Handler module, overriding any Options which disable apache--with-cgi Enable building of the CGI executable (implies--without-apache)--with-debug Comp Ile with debugging SYMBOLS--WITH-FPM Enable building of the FPM SAPI executable (implies--without-apache)--with-gmp Bui  LD with GMP Support--with-homebrew-curl include curl support via HOMEBREW--WITH-HOMEBREW-LIBXSLT include LIBXSLT support  Via Homebrew--with-homebrew-openssl include OpenSSL support via HOMEBREW--WITH-IMAP include IMAP EXTENSION--WITH-INTL  Include internationalization support--with-libmysql include (Old-style) Libmysql support instead of Mysqlnd--with-mssql Include mssql-db Support--with-pdo-oci include OracleDatabases (requries oracle_home be set)--with-pgsql Include PostgreSQL support--with-phpdbg Enable Building of the phpdb G SAPI executable (PHP 5.4 and above)--with-thread-safety Build with thread safety--with-tidy Include tidy Support--with OUT-BZ2 build without bz2 support--without-mysql Remove mysql/mariadb support--without-pcntl Build without Process Cont Rol support--without-pear Build without pear--head install HEAD version

Start the installation of PHP5.5.15, the installed Php-fpm.ini and php.ini are in the directory:/USR/LOCAL/ETC/PHP/5.5/below

Liondemacbook-pro:library lion$ Brew Install php55--with-mssql--with-homebrew-openssl--with-homebrew-libxslt-- 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.SF . net/project/machomebrew/bottles/curl-7.37.1.mavericks.bottle.tar.gz########################################## ############################## 100.0%==> pouring curl-7.37.1.mavericks.bottle.tar.gz==> CaveatsThis formula is Keg-only, which means it is not symlinked into/usr/local. Mac OS X already provides this software and installing another version inparallel can cause all kinds of trouble. Generally there is no consequences of this. If you build Yourown software and it requires this formula, you'll need to add to Yourbuild variables:ldflags:-l/usr/l Ocal/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==> downloading/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 files, 9.9M, Built in 2.2 minutes==> installing php55 dependency:gmp==> downloading https://downloads.sf.net/project/ 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/mirrorAlready 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==> CaveatsThe php.ini file Can be found inch:/usr/local/etc/php/5.5/php.ini✩✩✩✩pear✩✩✩✩if PEAR complains about permissions, ' fix ' the default PEA R permissions and config:chmod-r ug+w/usr/local/cellar/php55/5.5.15/lib/php pear config-set php_ini/usr/local/etc/ph P/5.5/php.ini✩✩✩✩extensions✩✩✩✩if you have issues with custom extension compiling, ensure thatyou is using the Brew version, by Placing/usr/local/bin Before/usr/sbin in your path:path= "/usr/local/bin: $PATH" PHP55 Extensions wil L always am compiled against this PHP. Install themusing--without-homebrew-php to enable compiling against system PHP. ✩✩✩✩php Cli✩✩✩✩if you wish-to-swap the PHP you have the command line and you should add the following to ~/.bashrc,~/.zs HRC, ~/.profile or your shell ' s Equivalent configuration File:export path= "$ (Brew--prefix homebrew/php/php55)/bin: $PATH" ✩✩✩✩fpm✩✩✩✩to launch PHP -FPM on Startup: * If The Is your first install: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 has the Homebrew.mxcl.php55.plist LOADED:LAUNCHCT L 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 you were using the brew version you need to make Sure/usr/local/sbin is before /usr/sbin in your path:path= "/usr/local/sbin: $PATH" Your may also need to edit the plistECT "UserName". Please note that the plist is called ' homebrew-php.josegonzalez.php55.plist ' in old versionsof this formula.  To has launchd start php55 at login:ln-sfv/usr/local/opt/php55/*.plist ~/library/launchagentsthen to load Php55 now: Launchctl Load ~/library/launchagents/homebrew.mxcl.php55.plist==> summary/usr/local/cellar/php55/5.5.15:477 Files, 43M, built in 3.9 minutes

If you see an error such as Configure:error:Cannot find OpenSSL in the process, perform the following command to update Xcode:

Xcode-select--install

In the PHP5 installation completed the prompt to write, how to do PHP5 and Mac with PHP and PHP-FPM replacement, after executing the following command, we can see that the current PHP version is up to date:

liondemacbook-pro:~ lion$ Echo ' export path=/usr/local/bin: $PATH ' >> ~/.bash_profileliondemacbook-pro:~ lion$ Echo ' Export path=/usr/sbin: $PATH ' >> ~/.bash_profileliondemacbook-pro:~ lion$ echo ' Export Path=/usr/local/sbin : $PATH ' >> ~/.bash_profileliondemacbook-pro:~ lion$ source ~/.bash_profile liondemacbook-pro:~ lion$ php-vphp 5.5.15 (CLI) (Built:aug 15:37:16) (DEBUG) Copyright (c) 1997-2014 the PHP groupzend Engine v2.5.0, Copyright (c) 1 998-2014 Zend technologiesliondemacbook-pro:~ lion$


Using the Brew Search php55-command, you can see which extensions can be installed, and then perform a brew install PHP55-XXX.

liondemacbook-pro:~ lion$ Brew Search PHP55-PHP55-AMQP php55-igbinary php55-msgpack php55-runkit Php55-varnis HPHP55-APCU php55-imagick Php55-mysqlnd_ms php55-scrypt php55-vldphp55-augmentedtypes php55-inclued php55 -oauth php55-snappy php55-wbxmlphp55-binpack php55-intl php55-opcache PHP55-SOLR php55-xcachephp55-b     Litz php55-ioncubeloader php55-parsekit php55-sphinx php55-xdebugphp55-boxwood php55-jsmin php55-pcntl Php55-spl-types php55-xhguiphp55-chdb php55-judy php55-pdflib php55-ssh2 php55-xhpphp55-couchbase ph P55-leveldb php55-pdo-dblib php55-stats php55-xhprofphp55-crypto php55-libevent php55-pdo-pgsql php55-st    Emmer php55-xmldiffphp55-dbase php55-libvirt php55-phalcon php55-sundown php55-yacphp55-dbus php55-lz4      Php55-proctitle PHP55-SVM php55-yafphp55-dmtx php55-lzf php55-propro php55-swoole Php55-yamlphp55-ev Php55-mailparse PHp55-protobuf php55-thrift php55-yarphp55-gearman php55-mcrypt Php55-pspell php55-tidy php55-yazphp     55-geoip php55-memcache php55-pthreads php55-timezonedb php55-ypphp55-gmagick php55-memcached PHP55-RAPHF Php55-tokyotyrant php55-yrmcdsphp55-graphdat php55-midgard2 Php55-redis Php55-twig php55-zmqphp55-hts       Canner Php55-mongo php55-redland php55-uploadprogress php55-zookeeperphp55-http php55-mosquitto 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 whether the PHP-FPM configuration is correct, and whether it starts 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 Successfulliondemacbook-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-fpmliondemacbook-pro:bin lion$ launchctl load-w ~/library/launchagents/ Homebrew.mxcl.php55.plist #查看9000端口是否在运行liondeMacBook-pro:bin lion$ lsof-i:9000command PID USER FD TYPE DEVICE S  Ize/off NODE namephp-fpm 51241 Lion 8u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) php-fpm 51243 Lion 0u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) php-fpm 51244 Lion 0u IPv4 0xce9d0f6417637937 0t0 TC P Localhost:cslistener (LISTEN) php-fpm 51245 Lion 0u IPv4 0xce9d0f6417637937 0t0 TCP localhost:cslistener (LISTEN) #关闭掉 PHP-FPM process, then view Port 9000, no monitoring liondemacbook-pro:bin lion$ PS aux|grep php-fpm|grep-v ' grep ' |awk ' {print $} ' |xargs Kill-9liondemacbook-pro:bin lion$ lsof-i:9000liondemacbook-pro:bin lion$

Set PHP-FPM boot run (in fact, in the installation of the prompt, also described):

Ln-sfv/usr/local/opt/php55/*.plist ~/library/launchagentslaunchctl Load ~/library/launchagents/ Homebrew.mxcl.php55.plist
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.