homebrew + php
Update
This is now been depracated and used as reference only. I opted to install php via source here
1. Cleanup existing PHP
So by default, OSX Leopard/Snow Leopard?, comes with apache2 and php installed.
mv /usr/local/include/php /usr/local/include/php.old mv /usr/local/lib/php /usr/local/lib/php.old |
- Install PHP
http://notfornoone.com/2010/07/install-php53-homebrew-snow-leopard/
~/Desktop% brew install php --with-apache --with-mysql --with-pgsql ==> Installing php dependency: jpeg ==> Installing php dependency: mcrypt ==> Installing php dependency: gettext ==> Installing php .... ==> cp ./php.ini-production /usr/local/Cellar/php/5.3.8/etc/php.ini ==> chmod 644 /usr/local/Cellar/php/5.3.8/lib/php/.lock ==> Caveats To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php5_module /usr/local/Cellar/php/5.3.8/libexec/apache2/libphp5.so The php.ini file can be found in: /usr/local/Cellar/php/5.3.8/etc/php.ini brew install php --with-apache --with-mysql --with-pgsql 452.56s user 272.47s system 126% cpu 9:31.75 total |
The most important here is the compiled libphp5.so which we will hook into apache2.
3. Hookup Apache2 to libphp5
Depending on your installation, edit httpd.conf and make sure you have this line
LoadModule php5_module /usr/local/Cellar/php/5.3.8/libexec/apache2/libphp5.so |
4. Test
% php -m #List all php modules mysql mysqli pdo_mysql pdo_pgsql pgsql /usr/local/bin% l php #brew makes the symlinks lrwxr-xr-x 1 rupert admin 27B 14 Nov 14:42 php@ -> ../Cellar/php/5.3.8/bin/php |
Well if you have a wordpress site, you can test if the whole thing works.
5. Restart Apache
sudo /Library/StartupItems/Apache2/Apache2 restart |
UPDATE: Dec 19, 2011
Maintaining php installations via homebrew is such a pain. I reverted back via source.
- Download php from source
- Configure
./configure --prefix=/usr/local/php5.3.8 \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --sysconfdir=/etc \ --with-config-file-path=/etc \ --with-zlib \ --with-zlib-dir=/usr \ --with-openssl \ --without-iconv \ --enable-exif \ --enable-ftp \ --enable-mbstring \ --enable-mbregex \ --enable-sockets \ --with-mysql=/usr/local/mysql \ --with-pdo-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-apxs2=/usr/local/apache2/bin/apxs |
- Make and Make Install
~/Desktop/php-5.3.8% sudo make install Password: Installing PHP SAPI module: apache2handler /usr/local/apache2.2.14/build/instdso.sh SH_LIBTOOL='/usr/local/apache2.2.14/build/libtool' libs/libphp5.so /usr/local/apache2.2.14/modules /usr/local/apache2.2.14/build/libtool --mode=install cp libs/libphp5.so /usr/local/apache2.2.14/modules/ cp libs/libphp5.so /usr/local/apache2.2.14/modules/libphp5.so Warning! dlname not found in /usr/local/apache2.2.14/modules/libphp5.so. Assuming installing a .so rather than a libtool archive. chmod 755 /usr/local/apache2.2.14/modules/libphp5.so [activating module `php5' in /usr/local/apache2.2.14/conf/httpd.conf] Installing PHP CLI binary: /usr/local/php5.3.8/bin/ Installing PHP CLI man page: /usr/share/man/man1/ Installing build environment: /usr/local/php5.3.8/lib/php/build/ Installing header files: /usr/local/php5.3.8/include/php/ Installing helper programs: /usr/local/php5.3.8/bin/ program: phpize program: php-config Installing man pages: /usr/share/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php5.3.8/lib/php/ [PEAR] Archive_Tar - installed: 1.3.7 [PEAR] Console_Getopt - installed: 1.3.0 [PEAR] Structures_Graph- installed: 1.0.4 [PEAR] XML_Util: upgrade to a newer version (1.2.1 is not newer than 1.2.1) [PEAR] PEAR - installed: 1.9.4 Wrote PEAR system config file at: /etc/pear.conf You may want to add: /usr/local/php5.3.8/lib/php to your php.ini include_path /Users/rupert/Desktop/php-5.3.8/build/shtool install -c ext/phar/phar.phar /usr/local/php5.3.8/bin ln -s -f /usr/local/php5.3.8/bin/phar.phar /usr/local/php5.3.8/bin/phar Installing PDO headers: /usr/local/php5.3.8/include/php/ext/pdo/ sudo make install 6.84s user 11.50s system 80% cpu 22.843 total |