Install PHP 5.3 with Homebrew on 10.6 Snow Leopard

Update
Please use the PHP formula at homebrew-php. This formula is updated and tested by many more users, and should be considered the go to forumla for PHP. You can also find additional PHP related formulae over at the homebrew-php repository.

Here are some notes on installing PHP 5.3.3 (the latest version at time of writing) with Homebrew, an awesome package manager for OS X.

  1. If you haven’t done so already, install Hombrew. Check out the installation instructions over at the Hombrew wiki.
  2. Grab the latest copy of my PHP brew and copy it into your Homebrew Formula directory.
    curl -O https://raw.github.com/ampt/homebrew/php/Library/Formula/php.rb
    mv php.rb `brew --prefix`/Library/Formula
  3. To see the available options:
    brew options php
  4. Run the brew install php command. The following will install PHP with Apache and MySQL support.
    brew install php --with-apache --with-mysql

    Or if you want to install php-fpm:

    brew install php --with-fpm

    Update: You can also just:

    # How much do you trust me...
    brew install https://raw.github.com/ampt/homebrew/php/Library/Formula/php.rb --with-apache --with-mysql

Once thats done you should be good to go.

Note: Depending on your setup you may want to add the following to your .bash_profile:

echo 'export PATH='`brew --prefix php`'/bin:$PATH' >> .bash_profile

This will ensure that BASH has the correct path to the PHP you just installed.

Bonus Points: xdebug

Install xdebug (there’s a brew for that) a great tool to help debug your PHP code:

brew install xdebug

106 thoughts on “Install PHP 5.3 with Homebrew on 10.6 Snow Leopard

  1. Thanks for making this formula. I ran it, and it seems to have installed PHP as well as PEAR. Does this install apache as well, or does it rely on the apache that comes with OSX? I’m trying to get from this install to writing a .php file and having it show up on http://localhost. Thanks!

  2. Yes it installs its own version of the Apache PHP module, you will need to edit your http.conf file to load it. Add the following to your http.conf, make sure to disable any other php module that may be loaded.

    LoadModule php5_module /your/homebrew/prefix/Cellar/php/5.3.3/libexec/apache2/libphp5.so

  3. Hi I got this error:
    Undefined symbols:
    “_iconv”, referenced from:
    __php_iconv_strlen in iconv.o
    _php_iconv_string in iconv.o
    _php_iconv_string in iconv.o
    __php_iconv_strpos in iconv.o
    __php_iconv_appendl in iconv.o
    __php_iconv_appendl in iconv.o
    _zif_iconv_substr in iconv.o
    _php_iconv_stream_filter_append_bucket in iconv.o
    _php_iconv_stream_filter_append_bucket in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _zif_iconv_mime_encode in iconv.o

    :(

    cirpo

  4. I was happy to have found this blog post as I was trying to quickly install PHP with FPM for use with Nginx. But, uhm…

    During the install of mysql (I installed with –with-mysql –with-fpm) I got

    ==> Downloading http://mysql.llarian.net/Downloads/MySQL-5.1/mysql-5.1.49.tar.gz
    ######################################################################## 100.0%
    Error: MD5 mismatch
    Expected: a90d87a71fa3c23dff6d78afc8e3184c
    Got: 599558ec26398497549e7770da1efd3b

    So I couldn’t proceed. The reason seems to be that Norton’s public DNS seem to block the site http://mysql.llarian.net as “malicious”.

    Any idea of why?
    Thanks

  5. I just downloaded the mysql-5.1.49.tar.gz and ran md5 on it and it seems to be correct (a90d87a71fa3c23dff6d78afc8e3184c). Not sure why yours is different.

    Remove mysql-5.1.49.tar.gz from ~/Library/Caches/Homebrew and try it again.

  6. Hi,

    i can not run php-fpm,help me! this is error:

    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/Cellar/php/5.3.3/lib/php/extensions/no-debug-non-zts-20090626/imagick.so’ – dlopen(/usr/local/Cellar/php/5.3.3/lib/php/extensions/no-debug-non-zts-20090626/imagick.so, 9): Symbol not found: _OnUpdateBool
    Referenced from: /usr/local/Cellar/php/5.3.3/lib/php/extensions/no-debug-non-zts-20090626/imagick.so
    Expected in: flat namespace
    in /usr/local/Cellar/php/5.3.3/lib/php/extensions/no-debug-non-zts-20090626/imagick.so in Unknown on line 0

  7. That error means that Homebrew has stripped all of the symbols out of php-fpm. I have just pushed a fix:
    php.rb

    thanks for the heads up

  8. Seemed to install ok. Now I’m trying to install Behat (http://everzet.com/Behat/) but it fails when trying:

    $ pear channel-discover pear.everzet.com

    Warning: require_once(Console/Getopt.php): failed to open stream: No such file or directory in System.php on line 21
    PHP Warning: require_once(Console/Getopt.php): failed to open stream: No such file or directory in /usr/local/Cellar/php/5.3.3/lib/php/System.php on line 21
    PHP Fatal error: require_once(): Failed opening required ‘Console/Getopt.php’ (include_path=’/usr/local/Cellar/php/5.3.3/lib/php’) in /usr/local/Cellar/php/5.3.3/lib/php/System.php on line 21

    What should I do?

  9. Hmmm, I think I have done everything right, however, I can’t get Apache to recognize .htaccess files. And I have changed all AllowOverride’s to All and all Options to All under Directory sections.

  10. Thanks a lot mate,

    The only change I had to make was to the bash_profile addition. The above script
    pointed to /usr/local/Cellar/php/5.3.3/ , whereas I needed it to point to the bin folder.

    So:
    echo 'export PATH='`brew --prefix php`/bin':$PATH' >> ~/.bash_profile

  11. for pdo support
    if ARGV.include? ‘–with-pgsql’
    args.push “–with-pgsql=#{Formula.factory(‘postgresql’).prefix}”
    # just add this line for pdo support
    args.push “–with-pdo-pgsql=#{Formula.factory(‘postgresql’).prefix}”
    end

  12. The download url for libpng has changed, a patch is waiting to be applied to Homebrew, an update has been applied and a brew up will fix it.

  13. Hi

    new to brew what is the messages about keg-only and duplication of libs. from stock OS X I also modified the libpng.rb to pick up 1.4.4 I guess I will apply the brew link command…

  14. I can’t install PEAR packages:

    $: pear update
    PHP Fatal error: Class ‘Console_Getopt’ not found in /usr/local/Cellar/php/5.3.3/lib/php/pearcmd.php on line 64
    PHP Stack trace:
    PHP 1. {main}() /usr/local/Cellar/php/5.3.3/lib/php/pearcmd.php:0

    Fatal error: Class ‘Console_Getopt’ not found in /usr/local/Cellar/php/5.3.3/lib/php/pearcmd.php on line 64

    Call Stack:
    0.0015 875776 1. {main}() /usr/local/Cellar/php/5.3.3/lib/php/pearcmd.php:0

    thanks

    cirpo

  15. Have a look at the xdebug.rb & apc.rb formulae they are good examples of PHP extensions, that is if you want compile and manage them with Homebrew.

    As of PHP 5.3.0 the mhash extension is emulated through the hash extension

  16. Sourceforge has a direct link, when you click to download the package there is a direct link option displayed on the “Your download will start…” page

  17. I had this same problem and it ended up being my homebrew install. I removed homebrew and reinstalled it and all was good. My homebrew was installed back in 10.5 and broke sometime between then and now (on 10.6)

  18. I wonder if it is possible to switch to different versions (ie: 5.2.16) for developing and testing?

  19. Yes it is possible, thats the great thing about Homebrew it uses the filesystem to manage software versions and organise the packages in general. Everything is in the Cellar which can be found under your Homebrew prefix.

    So for example in my Cellar I have two versions of PHP installed:
    Cellar/php/5.3.3
    Cellar/php/5.3.4

    One approach to install a different version of PHP would be:

    1. Edit your existing php.rb and configure it for PHP 5.2.16 or any PHP version for that matter

    2. Run brew install to install the different version of PHP.

      The Homebrew installation process symlinks the formula into Homebrew’s prefix. This is important if you use PHP CLI as a part of your tests, but not so much if you are only testing mod_php or php-fpm, fcgi etc

      If PHP CLI is important to your testing then the external brew command “brew switch” will be useful to you, it is located in Library/Contributions/examples. It allows you to switch between different versions of a formula.

      One more thing about the brew switch command, becuase OS X ships with php in /usr/bin/php your environment will look there first, so for brew switch to be effective with PHP CLI you must set your environment to look in Homebrew’s prefix first. This is also needed if you want to build any PECL extensions.

  20. Hello there, I have run through this process and got
    Apache, PHP, and Xdebug up and running. But when I go to start
    MySQL I get the following: $ mysql.server start Starting MySQL .
    ERROR! Manager of pid-file quit without updating file. I can’t seem
    to find any my.cnf on my system, so what cnf file does this mysql
    bundle use? Regards, Andrew

  21. Pingback: XDV, Plone and phpBB under one NGINX roof | ALAS doo

  22. Hi. Thanks for the package! Managed to install MySQL,
    Postgres and Apache, but when installing PHP 5.3.4 it failed with
    the following message: ==> cp ./php.ini-production
    /usr/local/Cellar/php/5.3.4/etc/php.ini cp:
    /usr/local/Cellar/php/5.3.4/etc/php.ini: No such file or directory
    Exit status: 1
    http://github.com/mxcl/homebrew/blob/master/Library/Formula/php.rb#L146
    ==> Environment HOMEBREW_VERSION: 0.7.1 HEAD:
    e1a07a8ed76cee7579377d5ab90b4d2514bf50cf HOMEBREW_PREFIX:
    /usr/local HOMEBREW_CELLAR: /usr/local/Cellar HOMEBREW_REPOSITORY:
    /usr/local HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
    Hardware: dual-core 64-bit penryn OS X: 10.6.6 Kernel Architecture:
    i386 Ruby: 1.8.7-174 /usr/bin/ruby =>
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    Xcode: 3.2.5 GCC-4.0: build 5494 GCC-4.2: build 5664 LLVM: build
    2333 MacPorts or Fink? false X11 installed? true ==> Build
    Flags CC: /usr/bin/cc => /usr/bin/gcc-4.2 CXX: /usr/bin/c++
    => /usr/bin/c++-4.2 LD: /usr/bin/cc =>
    /usr/bin/gcc-4.2 CFLAGS: -march=core2 -msse4.1 -w -pipe -O3
    CXXFLAGS: -march=core2 -msse4.1 -w -pipe -O3 CPPFLAGS:
    -I/usr/local/Cellar/gettext/0.17/include
    -I/usr/local/Cellar/libpng/1.2.44/include
    -I/usr/local/Cellar/libxml2/2.7.7/include LDFLAGS:
    -L/usr/local/Cellar/gettext/0.17/lib
    -L/usr/local/Cellar/libpng/1.2.44/lib
    -L/usr/local/Cellar/libxml2/2.7.7/lib MAKEFLAGS: -j2
    PKG_CONFIG_PATH:
    /usr/local/Cellar/gettext/0.17/lib/pkgconfig:/usr/local/Cellar/libpng/1.2.44/lib/pkgconfig:/usr/local/Cellar/libxml2/2.7.7/lib/pkgconfig
    Error: Failure while executing: cp ./php.ini-production
    /usr/local/Cellar/php/5.3.4/etc/php.ini I ran brew doctor, got ok
    as a response, tried installing PHP again to get the same error.
    Anyone ran into this issue too? Thanks again!

  23. Pingback: Apache, mySQL et PHP 5.3 avec Homebrew | Vincent Lemaire

  24. Hey, nice package.

    How about including FreeType?
    –with-freetypedir=/usr/X11R6

    Added that config option to your formula on a vanilla Mac OSX 10.6 install. worked.

  25. Hey I modified your php.rb formula to produce the 5.3.5 release.. all seems to go well no erros or warning but the result /usr/local/Cellar/php/5.3.5/libexec/apache2/libphp5.so
    does not exist… have you tried this yet???

    -dale

  26. I just tried compiling PHP 5.3.5 on 10.6.6 and got the same result, no errors but no libphp5.so
    I’ll post back if I figure anything out.

  27. I just built PHP 5.3.5 on 10.6.6 using the –with-apache option, seemed to work for me the libphp5.so is there

  28. decided to re-build my dev machine and decided to use homebrew for packages this time(never used before, but it looks like it will make things much easier),
    so I ran brew install php –with-apache –with-mysql on a fresh, fully updated 10.6.6
    All went well until the ./configure for php. For some reason it couldn’t find freetype.h?
    I looked in /usr/X11 and found it…

    $ find /usr/X11 -name freetype.h
    /usr/X11/include/freetype2/freetype/freetype.h

    any ideas?
    thanks in advance for all the excellent work done here and any pointers you can give.

    ......

    checking whether to enable truetype string function in GD... yes
    checking whether to enable JIS-mapped Japanese font support in GD... no
    checking for fabsf... yes
    checking for floorf... yes
    checking for jpeg_read_header in -ljpeg... yes
    checking for png_write_image in -lpng... yes
    If configure fails try --with-xpm-dir=
    configure: error: freetype.h not found.
    Exit status: 1

    http://github.com/mxcl/homebrew/blob/master/Library/Formula/php.rb#L140

    ==> Environment
    HOMEBREW_VERSION: 0.7.1
    HEAD: f4ec74a8cacecf9594302161e4f934b75fb64952
    HOMEBREW_PREFIX: /usr/local
    HOMEBREW_CELLAR: /usr/local/Cellar
    HOMEBREW_REPOSITORY: /usr/local
    HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
    Hardware: dual-core 64-bit penryn
    OS X: 10.6.6
    Kernel Architecture: i386
    Ruby: 1.8.7-174
    /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    Xcode: 3.2.5
    GCC-4.0: build 5494
    GCC-4.2: build 5664
    LLVM: build 2333
    MacPorts or Fink? false
    X11 installed? true

  29. sorry for all the posting (should have checked all this and posted once :)

    changing the path in the php.rb from

    –with-freetype-dir=/usr/X11/lib
    to
    –with-freetype-dir=/usr/X11R6

    fixed the issue for me

  30. Heyyyyy, great stuff!
    Thanks for it, still downloading but I’m sure it’ll work.

    I really like the simplicity of the process hehe :)

    Cheers,
    Diogo

  31. Just wanted to say thanks and keep this post alive :)

    I’m new to homebrew and maybe a lot of my shock & awe is how sexy it is but this formula (and more importantly your upkeep & transparency with it) is REALLY nice.

    I’ll likely be forking your formula and upgrading it as I feel I’ll be using this often ;)

  32. I was having a world of trouble compiling and installing php/mysql.

    I downloaded and installed homebrew, ran the install and hey presto worked first time!

    Thank you

  33. I’ve also got this problem, the cause is:

    make: *** No rule to make target `/private/tmp/homebrew-php-5.3.5-XPCq/php-5.3.5/ext/date/php_date.c', needed by `ext/date/php_date.lo'. Stop.

    To find it out I had to modify the php.rb as follows to copy the build directory somewehre where i could try it out myself (my first Ruby coding ever):

    ...
    system "make"
    # added:
    system "cp -r . /tmpt/phpbrew"
    system "make install"
    ...

    The formula should fail if the command it calls fails (with an informative error message, of course).

  34. Please ignore my previous misleading comment, however I managed to get PHP 5.3.4 and .5 installed. The following simple fix of the php.rb is needed –
    repalce

    system "make install"

    system "cp ./php.ini-production #{prefix}/etc/php.ini"

    with

    system "make install"

    system "mkdir -p #{prefix}/etc/php.ini"
    system "cp ./php.ini-production #{prefix}/etc/php.ini"

  35. One more fix :-) This comments should really have the possibility to be edited for the no-so-smart people like me :-)

    The mkdir command should be of course one element shorter:
    system “mkdir -p #{prefix}/etc/

  36. OS X 10.6 WORKS (ONLY) WITH 64b APACHE

    Beware: for 10.6.6 you should NOT run Apache in 32b mode unless it is what the php library was built for. At the end of the installation brew says:

    For 10.5 and Apache:
    Apache needs to run in 32-bit mode. You can either force Apache to start
    in 32-bit mode or you can thin the Apache executable.

    You should first verify what architectures the php library is built for:

    $ file /usr/local/Cellar/php/5.3.5/libexec/apache2/libphp5.so
    /usr/local/Cellar/php/5.3.5/libexec/apache2/libphp5.so: Mach-O 64-bit bundle x86_64

    as you can see, in my case it only supports 64b Intel. Checking Apache:

    $ file /usr/sbin/httpd
    /usr/sbin/httpd.origx86_64: Mach-O universal binary with 3 architectures
    /usr/sbin/httpd.origx86_64 (for architecture x86_64): Mach-O 64-bit executable x86_64
    /usr/sbin/httpd.origx86_64 (for architecture i386): Mach-O executable i386
    /usr/sbin/httpd.origx86_64 (for architecture ppc7400): Mach-O executable ppc

    - you can is that in my case the same (mach-O 64b) architecture is the first one so no changes to httpd are necessary and actually forcing Apache to be 32b would lead to

    Cannot load …/libphp5.so into server: dlopen(…): no suitable image found. Did find: …/libphp5.so: mach-o, but wrong architecture

  37. PHP 5.3.5 AT 10.6.6 FAILS TO INSTALL PEAR

    Pear wasn’t installed – after trying it manually and adding –force and –debug to the Makefile I got this:

    Warning: fopen(/usr/local/Cellar/php/5.3.5/lib/php/.depdb): failed to open stream: No such file or directory in phar:///private/tmp/homebrew-php-5.3.5-XPCq/php-5.3.5/pear/install-pear-nozlib.phar/PEAR/DependencyDB.php on line 548

    I therefore installed it manually:

    shell$ curl http://pear.php.net/go-pear.phar > go-pear.phar
    shell$ /usr/local/bin/php go-pear.phar
    # choose:
    1. Installation base ($prefix): /usr/local/Cellar/php/5.3.5/lib/php
    4. Binaries directory: /usr/local/Cellar/php/5.3.5/bin
    6. Documentation directory: /usr/local/Cellar/php/5.3.5/lib/php/doc
    5. PHP code directory ($php_dir): /usr/local/Cellar/php/5.3.5/lib/php
    # and allow pear to update the include path in php.ini

    shell$ ln -s /usr/local/Cellar/php/5.3.5/bin/pear /usr/local/bin/pear

    Plus make sure you have no (inconsistent) ~/.pearrc

  38. n00b note:
    If you get php running but still see source instead of a rendered php page or only part of a page renders ‘short_open_tag’ on line 226 of /usr/local/etc/php.ini needs to be set to ‘on’.

  39. Good morning!

    I’ve been having major problems getting PHP to build, which I’m sure aren’t anything to do with the formula, but rather a problem with my setup.

    When running brew install php --with-fpm --with-mysql --with-intl I’m getting the following linker errors:

    Undefined symbols:
    “_xsltRegisterExtModuleFunction”, referenced from:
    _zm_startup_xsl in php_xsl.o
    _zm_startup_xsl in php_xsl.o
    “_xsltUnregisterExtModuleFunction”, referenced from:
    _zm_shutdown_xsl in php_xsl.o
    _zm_shutdown_xsl in php_xsl.o
    “_xsltFreeTransformContext”, referenced from:
    _php_xsl_apply_stylesheet in xsltprocessor.o
    “_xsltGenericError”, referenced from:
    _xsl_ext_function_php in xsltprocessor.o
    “_xsltCleanupGlobals”, referenced from:
    _zm_shutdown_xsl in php_xsl.o
    “_xsltApplyStylesheetUser”, referenced from:
    _php_xsl_apply_stylesheet in xsltprocessor.o
    “_xsltParseStylesheetDoc”, referenced from:
    _zif_xsl_xsltprocessor_import_stylesheet in xsltprocessor.o
    “_xsltFreeStylesheet”, referenced from:
    _xsl_objects_free_storage in php_xsl.o
    _zif_xsl_xsltprocessor_import_stylesheet in xsltprocessor.o
    “_xsltLibxsltVersion”, referenced from:
    _zm_info_xsl in php_xsl.o
    “_xsltXPathGetTransformContext”, referenced from:
    _xsl_ext_function_php in xsltprocessor.o
    “_xsltSaveResultToFilename”, referenced from:
    _zif_xsl_xsltprocessor_transform_to_uri in xsltprocessor.o
    “_xsltLibxmlVersion”, referenced from:
    _zm_info_xsl in php_xsl.o
    “_xsltSetGenericErrorFunc”, referenced from:
    _zm_deactivate_xsl in php_xsl.o
    _zm_activate_xsl in php_xsl.o
    “_xsltNewTransformContext”, referenced from:
    _php_xsl_apply_stylesheet in xsltprocessor.o
    “_xsltGenericErrorContext”, referenced from:
    Undefined symbols:
    _xsl_ext_function_php in xsltprocessor.o
    “_xsltRegisterExtModuleFunction”,”_exsltRegisterAll”, referenced fromreferenced :
    from:
    _zm_startup_xsl _zm_startup_xsl inin php_xsl.ophp_xsl.o

    ” _xsltSaveResultToString”, referenced from_zm_startup_xsl:
    in php_xsl.o
    “_xsltUnregisterExtModuleFunction_zif_xsl_xsltprocessor_transform_to_xml” ,in referencedxsltprocessor.o
    fromld::
    symbol ( s ) not_zm_shutdown_xsl foundin
    php_xsl.o
    _zm_shutdown_xsl in php_xsl.o
    “_xsltFreeTransformContext”, referenced from:
    _php_xsl_apply_stylesheet in xsltprocessor.o
    “_xsltGenericError”, referenced from:
    _xsl_ext_function_phpcollect2: in xsltprocessor.o
    “_xsltCleanupGlobals”, referencedld returned 1 exit status
    from:
    _zm_shutdown_xsl in php_xsl.o
    “_xsltApplyStylesheetUser”, referenced from:
    _php_xsl_apply_stylesheet in xsltprocessor.o
    “_xsltParseStylesheetDoc”, referenced from:
    _zif_xsl_xsltprocessor_import_stylesheet in xsltprocessor.o
    “_xsltFreeStylesheet”, referenced from:
    _xsl_objects_free_storage in php_xsl.o
    _zif_xsl_xsltprocessor_import_stylesheet in xsltprocessor.o
    “_xsltLibxsltVersion”, referenced from:
    _zm_info_xsl in php_xsl.o
    “_xsltXPathGetTransformContext”, referenced from:
    _xsl_ext_function_php in xsltprocessor.o
    “_xsltSaveResultToFilename”, referenced from:
    _zif_xsl_xsltprocessor_transform_to_uri in xsltprocessor.o
    “_xsltLibxmlVersion”, referenced from:
    _zm_info_xsl in php_xsl.o
    “_xsltSetGenericErrorFunc”, referenced from:
    _zm_deactivate_xsl in php_xsl.o
    _zm_activate_xsl in php_xsl.o
    “_xsltNewTransformContext”, referenced from:
    _php_xsl_apply_stylesheet in xsltprocessor.o
    “_xsltGenericErrorContext”, referenced from:
    _xsl_ext_function_php in xsltprocessor.o
    “_exsltRegisterAll”, referenced from:
    _zm_startup_xsl in php_xsl.o
    “_xsltSaveResultToString”, referenced from:
    _zif_xsl_xsltprocessor_transform_to_xml in xsltprocessor.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [sapi/fpm/php-fpm] Error 1
    make: *** Waiting for unfinished jobs….
    make: *** [sapi/cli/php] Error 1
    Exit status: 2

    … clearly a problem with the XSL library. I was wondering if anyone has had the same sort of issue and, if so, knows a fix?

  40. OK. No more spam. It was quite a simple fix: I followed the instructions for installing and linking libxslt for Homebrew, which can be found at the Installing Nokogiri page. PHP now builds and installs correctly.

  41. I need php-sqlite and php-cli as module. How do we patch php.rd to include this before the build?

    thanks.

  42. Hello there!

    I’ve been using your Formula for a month now, and it’s perfect. Also, it’s nice you keep updating it. :)

    Since I’m rather new to Ruby, is there a way you could include (optional, if you want) the Suhosin patch for PHP? It would be another killer addition.

    Thanks in advance!

  43. Thanks for this, looks really easy BUT it’s not quite working for me!

    I’ve tried brew up, but am still getting this error after “brew install php –with-apache –with-mysql”:

    ==> Downloading ftp://mirror.internode.on.net/pub/gentoo/distfiles/libmcrypt-2.5
    ######################################################################## 100.0%
    curl: (28) FTP response timeout
    Error: Failure while executing: /usr/bin/curl -f#LA Homebrew\ 0.8\ (Ruby\ 1.8.7-174;\ Mac\ OS\ X\ 10.6.7) ftp://mirror.internode.on.net/pub/gentoo/distfiles/libmcrypt-2.5.8.tar.gz -o /Users/me/Library/Caches/Homebrew/mcrypt-2.5.8.tar.gz

    Can anyone help?

  44. Thanks for your formula, however I have an issue that when I use it on my machine the php-cgi binary is not created when I specify the –with-fpm switch. The php-fpm binary is created.

    I have cleared things out quite a few times now and each time it happens. Any ideas would be very welcome.

    Thanks, Russell

  45. If you need to use the php-cgi binary, at this stage you will have to enable it yourself, by editing the php.rb brew and adding –enable-cgi to the list of configure options.

  46. The reason why is that which mysql_config does not return anything on my system :( (seems like which is broken)

    Is there a problem just on my system (10.6.7) or have anyone else experienced anything simular?

  47. Added “–enable-cgi” to the list of configure options (tried appending and inserting it right after “–prefix=#{prefix}”), everything works fine, but no php-cgi-executable is created.

    Any Ideas?

    php version is 5.3.6, brew 0.8, OS X 10.6.7

  48. Maybe double check the enable cgi-flag, note the double dash: “–enable-cgi”

  49. Sorry just realised its WordPress stripping the dashes… I ran a test build with --enable-cgi and the php-cgi binary is there. Not sure why yours isn’t showing up. I placed --enable-cgi as the last item in the configure args, shouldn’t make any difference though.

  50. hmm the make is failing with this error:

    -liconv -lm -lxml2 -lz -liconv -lm -lxml2 -lz -liconv -lm -lxslt -lxml2 -lz -licucore -lm -o sapi/cli/php
    Undefined symbols for architecture x86_64:
    “_iconv”, referenced from:
    __php_iconv_appendl in iconv.o
    __php_iconv_strlen in iconv.o
    _php_iconv_string in iconv.o
    __php_iconv_strpos in iconv.o
    _zif_iconv_substr in iconv.o
    Undefined symbols for architecture x86_64:
    “_iconv”, referenced from:
    __php_iconv_appendl in iconv.o
    __php_iconv_strlen in iconv.o
    _php_iconv_string in iconv.o
    __php_iconv_strpos in iconv.o
    _zif_iconv_substr in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _php_iconv_stream_filter_append_bucket in iconv.o

    (maybe you meant: _zif_iconv_mime_decode_headers, _zif_iconv_set_encoding , _php_iconv_string , _zif_iconv_get_encoding , _zif_iconv_mime_encode , _iconv_module_entry , _iconv_functions , _zif_iconv_mime_decode , _php_if_iconv , _zif_iconv_substr , _zif_ob_iconv_handler , _zif_iconv_strrpos , _zif_iconv_strlen , _iconv_globals , _zif_iconv_strpos )
    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    make: *** [sapi/fpm/php-fpm] Error 1

    i had to install libiconv manually for it to even get that far..
    any idea?

  51. Same error here :(

    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status

  52. Pingback: Forget MAMP: Install Apache + PHP5.2 + MySQL5 with macports | Mac

  53. Iconv issues are a SL/Lion issue, which require using 5.3-nightly sources.. Apple patched this upstream but the issue wasn’t fixed by the community until a few months ago.

    I’ve tried everything to use MacPorts, Brew, or System iconv (All architectures would naturally be there if with MacPorts you built with +Universal, not brew, just the host architecture (x86_64)), but php is too dumb and was ignoring –with-iconv-dir in configure in 5.3.x up to 5.3.7, maybe still 5.3.8 also.

    The broken build steps in the scripts look for iconv only in one place, and even manually modifying configure to add -L/opt/local/lib or similar won’t fix the issue. Try a nightly version or the 5.4 beta that was just released if you’re not on 10.5.

    - James

  54. Pingback: brewでphpをインストール | NakajiJapan

  55. any movement on PHP 5.4 installing this way yet?
    this 5.3 way is remarkable, used in numerous times now.
    thanks

  56. I’ve tested RC1 & RC2, they seem to be working well, but will hold off from updating the brew until the final release.

  57. Pingback: MAMP Helps « The Journeyler

  58. Pingback: Running WordPress on Heroku | Wisps & Snippets

  59. Pingback: WordPress on Pow: Rack-powered WP. | Wisps & Snippets

  60. Pingback: Symfony2 and MAMP | thedrearlight

  61. Had trouble getting 5.3.10 to start (brew install php –with-fpm –with-mysql), and found that both org.php-fpm.plist and php-fpm.conf specify /usr/local/Cellar/php/5.3.10/var/log/php-fpm.log as log file. However, the directory /usr/local/Cellar/php/5.3.10/var/log/ is not created. Also, there is an empty log file at /usr/local/var/log/php-fpm.log.

    I can work around this by creating /usr/local/Cellar/php/5.3.10/var/log/ and ignoring /usr/local/var/log/php-fpm.log, but perhaps this should be sorted out. I would prefer the log file being /usr/local/var/log/php-fpm.log. As it is now, I have linked it to the one in the cellar.

    I also get this:

    [11-Apr-2012 10:37:35] ALERT: [pool www] pm.min_spare_servers(5) and pm.max_spare_servers(35) cannot be greater than pm.max_children(5)

    Changing max_children to 35 solves that.

  62. Pingback: Vim初心者によるVim導入記録(CodeSnifferインストール+シンタックスチェック syntastic設定編) | Code Life

  63. Thanks a lot for this article, i tried to install xdebug and brew didn’t find this formula. Now, if you want to setup xdebug you have to type this:
    brew install xdebug-php