- Note that this package will ONLY work on Mac OS 10.4, NOT 10.3! I installed it on 10.3 and the installation failed at the end, and then the Apache server would not restart because it could no longer load the php shared library. I can't find any precompiled version of PHP 5.2 available for Mac OS 10.3.
- MacOS Package (.pkg) Installer. The easiest way to install MacPorts on a Mac is by downloading the pkg or dmg for Catalina, Mojave, High Sierra, Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion, Snow Leopard, Leopard or Tiger and running the system's Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion.
Mac App Store: Click a Button to Install an App. We’re all used to app stores on our phones, but on the desktop they remain an oddity. Still, the Mac App Store is a decent first place to check. Open the store, search for the app you want, and click “Get” then “Download.”. Mac users have a choice of either a binary or a source installation. In fact, your OS X probably came with Apache and PHP preinstalled. This is likely to be quite an old build, and it probably lacks many of the less common extensions. However, if all you want is a quick Apache + PHP + MySQL. How to Install phpMyAdmin on MacOS Introduction. PhpMyAdmin is a free and open source tool for the administration of MySQL and MariaDB.As a portable web application written in PHP, it has become one of the most popular administration tool for MySQL. In this tutorial, we will learn the steps involved in the installation of phpMyAdmin on MacOS.
You need to make sure you have the Apple Developer Tools, BSD Subsystem, and an installation of X before you try installing PHP-GTK 2. Although the BSD subsystem is installed by default on Mac OS X, you need select the Developer Tools and X Server manually. Although you can use any X server, the easiest would be to use the one Apple provides by default on it's Mac OS X installer.
Get MacPorts (previously knows as DarwinPorts) or Fink and install it. You can use either to install a version of X (if you decided not to use Apple's default distribution), and Gtk+ itself. Both Fink and MacPorts provide versions 2.6 and above of Gtk+. Also make sure you have a version of PHP that is atleast 5.2, MacPorts provides a package. Type php -v on your Terminal to find out your version. If you want to manually compile PHP you can do so: Although you may install it anywhere, /usr/local/ is usually considered a good place. MacPorts installs PHP into /opt/local/.

Now get the latest checkout of PHP-GTK and compile it: Remember to replace /usr/local/ with the actual directory in which you installed PHP. For example, if you installed PHP 5.2 using MacPorts, you would enter /opt/local/ instead.
Finally, copy over the php.ini-recommended file to /usr/local/lib/php.ini and change the value of extension_dir to the directory where php_gtk2.so resides. This is usually something like: /usr/local/lib/php/extensions/no-debug-non-zts-some-date. You may want to create a new symbolic link in /usr/bin/ that points to /usr/local/bin/php. Again, the directory may be /opt/local/ instead of /usr/local/ depending on where your installation of PHP resides.
Now continue with Testing your installation.

Installing php-mcrypt should be a cakewalk on Mac OS X with brew using the command 'brew install php54-mcrypt' but at times things do not work out this easily and that is when you have to end up building and installing php54-mcrypt manually. It is an easy process and here is how you can do it. Another way to install PHP-Mcrypt is using Macports.
Step 1: Install mcrypt library using homebrew
sudo brew install mcrypt
You might get an error that says cowardly refusing to sudo while using brew, that can be easily fixed as well, see this.
Step 2: Download and extract PHP using this link into a folder.
Step 3: Next step is to open the mcrypt folder in a command line and issue the phpize command and then follow it using the regular make and install commands. You might want to use the following commands for the entire process:
cd ~/Downloads
wget https://github.com/php/php-src/archive/PHP-5.4.17.zip
unzip PHP-5.4.17.zip
cd php-src-PHP-5.4.17/ext/mcrypt/
/usr/bin/phpize
./configure
make

sudo make install
In the above series of steps,if for some reason you get blank outputs from the various property values after running the /usr/bin/phpize command, then you need to install xcode developer tools before proceeding further. Here is how you do it.
xcode-select --install
Running the command above will bring up a prompt as shown below:
Login password for mac. If you encounter errors like the `brew link` step did not complete successfully or mcrypt.h not found then these can be fixed by asking brew to link mcrypt properly - issue the following commands in your terminal:
sudo brew link mcrypt
Try the following command in case above fails:
sudo brew link --overwrite mcrypt

After you are done with this, all you need to do is open the php.ini file available in /etc/ folder and add the following lines towards the end of the file:
extension=mcrypt.so
Install Php For Mac Windows 10
extension_dir=/usr/lib/php/extensions/no-debug-non-zts-20100525/
Install Php Mac Brew
The second line extension_dir is optional. Restart Apache using sudo apachetctl restart command and you are all set 🙂
PS: If you encounter a brew link error then you can take a look at this post (browser towards the end of that article)