Install PHP 5.3 with Homebrew on 10.6 Snow Leopard
Posted on by ampt
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.
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.
- If you haven’t done so already, install Hombrew. Check out the installation instructions over at the Hombrew wiki.
- 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
- To see the available options:
brew options php
- 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
101 thoughts on “Install PHP 5.3 with Homebrew on 10.6 Snow Leopard”
Exactly what I was looking for! Thanks
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 localhost. Thanks!
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
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
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 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 mysql.llarian.net as “malicious”.
Any idea of why?
Thanks
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.
Nice job! Why not push this to Homebrew proper? It came in handy when I was forced to run some crusty PHP code on my dev machine tonight.
Hi,
i can not run php-fpm,help me! this is error:
PHP 64
Call Stack:
0.0015 875776 1. {main}() /usr/local/Cellar/php/5.3.3/lib/php/pearcmd.php:0
thanks
cirpo
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
When installing PHP 5.3.4 using this formula I get the following error:
“It looks like an autotools configure failed.”
Any ideas?
Thanks
I would like to include a support for freetds (to talk to mssql). Suggestions?
Well I like what I see in the brew ruby files. But I don’t have the knowledge on how to get the url to down load the file. For instance imagick is a sourceforge. I can get the url up to the download page. The example returns html….
example:
curl sourceforge.net/projects/imagemagis/6.6.6-sources/ImageMagick-6.6.6-4.tar.gz/download
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
Your right gee I am blind… Thanks