Background Story for the Article
I stopped using prebuilt applications that you can easily purchase online, for example MAMP and WebStart for Mac OS X, due to their limitations and in some instances lack up support and/or frequency of updates. In other instances the way that the servers were built were not designed for users that are of a developer level and thus did not fit my needs. I shortly after getting frustrated with all these quick solutions and their inability to give me the flexibility I needed to test my apps as rigorously as I needed tossed them to the side, even after paying money to use them and invested $20 in Apple’s OS X Server in the App Store.
This application gave me all the tools I needed to run a web server natively from my MacBook Pro without all hassles of dealing with a third party app. However, once I finished figuring out OS X Server’s simple interface and started digging into what they had installed natively I was slightly disappointed by the fact that there was no option to choose a higher version of PHP. As of this post, it is currently PHP 5.3.15 and I need the additional features of PHP 5.4 in order to continue doing my work as I please.
It is at this point that I started searching online for a way to upgrade it to work with as similar a configuration as possible. During this time however, I had MacPorts installed and for some reason the compiling always failed. I set it to the side for a while since I had to continue working but eventually went back to researching the issue. After reading several reports on the subject I found that MacPorts was the one giving me the issues because of mismatched libraries and how they were not located in
/usr with the rest of the system’s libraries. I eventually came to the conclusion that MacPorts needed to be replaced.
I compared most of the package managers I could find and found that HomeBrew was the solution due to it compiling the libraries for the system with native libraries and symlinking the folders into
/usr/local so that the system could see the libraries and use them appropriately like any other *Nix system.
How to Setup and Configure PHP
The following is a description of the steps needed to successfully compile PHP for OS X Server from setting up OS X Server to Installing PHP itself. Thanks for your patiences and enjoy!
In order for this to work natively with a front end interface, you will need to uninstall any other application that installs PHP or Apache to your system and all the folders it creates. I used AppDelete by Reggie Ashworth and have found it to be quite worth the money I bought it for. It removes every instance of the software installed that can be found. After that I went and bought and installed Apple’s OS X Server from the App Store and installed it after making sure that the latest XCode was installed with the Command Line Utilities.
Once OS X Server is installed and you finish the setup for it, go install HomeBrew with the following command:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Once that is complete you will then need to install libraries required for PHP as follows:
brew install freetype gd jpeg libpng pcre wget xmp libxmp
After that you will need to download PHP and configure it as follows. Please keep in mind that I have not altered the config command much due to my desire to keep it in line with the default configuration. However you can change it as you see fit.
# Download PHP 5.4.14+
./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 --with-jpeg-dir=/usr --with-png-dir=/usr --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 --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=/usr --with-pgsql=/usr --with-pdo-pgsql=/usr --with-mcrypt=/usr
If you find any libraries missing you can always do a Google search to find out what it is in order to resolve that dependency issue. But overall it is quite easy once you figure out what needs to be done! Good luck and have fun!