Upgrade to PHP 5.5 on OS X 10.8 Mountain Lion
The following is a rapid installation of PHP 5.5 on OS X 10.8. This compiles 5.5 from source, including two required libraries and finding the appropriate configure command.
The following is a rapid installation of PHP 5.5 on OS X 10.8. This compiles 5.5 from source, including two required libraries and finding the appropriate configure command. If you are comfortable at the command line, and especially if you are comfortable compiling your own binaries, then this should take no more than 30 minutes, with the majority being the actual PHP compilation.
Let's jump right in. Here's an overview of the steps:
- Back-up existing binaries
- Install jpeg and png libs
- Download PHP source
- Adjust Apple's ./configure command
- Build & install
1. Back up existing PHP binaries
php -i > ~/php-config-2013-08-15 sudo cp /usr/libexec/apache2/libphp5.so ~/libphp5.so.apple sudo cp /usr/bin/php ~/php.apple
2. Install JPEG and PNG libs
To compile php 5.5, you'll need development libs for JPEG and PNG compression. Download and configure/make/install the following:
- http://www.ijg.org/files/jpegsrc.v9.tar.gz
- http://hivelocity.dl.sourceforge.net/project/libpng/libpng16/1.6.5/libp…
3. Download PHP 5.5 Source
Get the latest 5.5 code from here.
4. Adjust the Previous OS X ./configure command for PHP 5.3 (or 5.4)
For a great starting point on your configure command, run the following:
php -i |grep configure
This is the ./configure command that Apple used to compile your installed PHP. With just a few adjustments we can whip this into shape. I'll leave the details discovery to you and show you my resulting ./configure command. Naturally, you'll need to change your working directory to be the expanded source code you just downloaded.
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/private/etc --with-apxs2=/usr/sbin/apxs --enable-cli --with-config-file-path=/etc --with-libxml-dir=/usr --with-openssl=/usr --with-kerberos=/usr --with-zlib=/usr --enable-bcmath --with-bz2=/usr --enable-calendar --disable-cgi --with-curl=/usr --enable-dba --enable-exif --enable-fpm --enable-ftp --with-gd --with-freetype-dir=/usr/X11R6 --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --enable-gd-native-ttf --with-icu-dir=/usr --with-iodbc=/usr --with-ldap=/usr --with-ldap-sasl=/usr --with-libedit=/usr --enable-mbstring --enable-mbregex --with-mysql=mysqlnd --with-mysqli=mysqlnd --without-pear --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/mysql/mysql.sock --with-readline=/usr --enable-shmop --with-snmp=/usr --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-iconv-dir=/usr --with-xsl=/usr --enable-zip --with-pcre-regex --with-pgsql=/usr --with-pdo-pgsql=/usr
5. Build and Install
This is where I must tell you that you must take full responsibility for your own system. If you do not understand the inherent risks involved in what you are doing (if you aren't adequately eye-brow-raised at any online resource that tells you to 'sudo make install'), then please find a different way (MAMP?) to update your development environment.
After running your ./configure command, and knowing that you have your binary apache .so and php backed up, it's time to build PHP 5.5 and install it:
make sudo make install
Summary
Let me show you a hypothetical single-script for all of this. I have not tested this, so use with care. For that reason, I have not included the install step.
mkdir -p ~/php55/backups cd ~/php55/backups php -i > ./php-config-2013-08-15 sudo cp /usr/libexec/apache2/libphp5.so ./libphp5.so.apple sudo cp /usr/bin/php ./php.apple cd ../ wget http://www.ijg.org/files/jpegsrc.v9.tar.gz tar -zxf jpegsrc.v9.tar.gz cd jpeg-9 ./configure --enable-shared make && sudo make install cd ../ wget http://hivelocity.dl.sourceforge.net/project/libpng/libpng16/1.6.5/libpng-1.6.5.tar.gz tar -zxf ./libpng-1.6.5.tar.gz cd libpng-1.6.5 ./configure make && sudo make install cd ../ wget http://us2.php.net/distributions/php-5.5.3.tar.gz tar -zxf ./php-5.5.3.tar.gz cd php-5.5.3 ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/private/etc --with-apxs2=/usr/sbin/apxs --enable-cli --with-config-file-path=/etc --with-libxml-dir=/usr --with-openssl=/usr --with-kerberos=/usr --with-zlib=/usr --enable-bcmath --with-bz2=/usr --enable-calendar --disable-cgi --with-curl=/usr --enable-dba --enable-exif --enable-fpm --enable-ftp --with-gd --with-freetype-dir=/usr/X11R6 --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --enable-gd-native-ttf --with-icu-dir=/usr --with-iodbc=/usr --with-ldap=/usr --with-ldap-sasl=/usr --with-libedit=/usr --enable-mbstring --enable-mbregex --with-mysql=mysqlnd --with-mysqli=mysqlnd --without-pear --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/mysql/mysql.sock --with-readline=/usr --enable-shmop --with-snmp=/usr --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-iconv-dir=/usr --with-xsl=/usr --enable-zip --with-pcre-regex --with-pgsql=/usr --with-pdo-pgsql=/usr make # please sudo make install at your own discretion