You Are Here: Home » How-To » Linux

Install PHPMcrypt in Mac OS X Yosemite – MacPorts [How To]

By Debjit on November 29th, 2014 

We had earlier told you about how to install php-mcrypt easily on Mac OS X (Yosemite, Mavericks, Mountain Lion) using brew. But, I just stumbled upon another very very easy way to install php-mcrypt using MacPorts and we will show you how to do it on Apple Mac OS X Yosemite.

1. First of all you have to install XCode and the xcode command line tools. XCode can be installed from the Mac App Store and then the xcode command line tools can be installed from the command line using this command:

xcode-select --install


xcode command line tools

2. After this is done, head over to and choose the MacPorts binary for your version of Apple Mac OS X in order to install it

Steps 1 and 2 can be skipped if you have already installed MacPorts on your system earlier

3. Now check for the version of PHP installed on your Mac using the command:

php -v

4. If the version of PHP that you get is 5.5, then use the following command to install php-mcrypt:

sudo port install php55-mcrypt

5. If the version of PHP that you get is 5.4, then use the following command instead:

sudo port install php54-mcrypt

Please note that if you are doing a fresh install of MacPorts then you need to switch to a new tab in order to run the commands in this step.

6. After you are done with the above steps, you will now have to add the path to this extension at the end of the php.ini file located in your /etc/ folder.


7. Next, save the the config file - /etc/php.ini and restart Apache with this command:

sudo apachectl restart

Please note that in a fresh Mac OS X install, the file php.iniwill not be present in the /etc/ directory and instead there will be a php.ini.default. You need to make a copy of this file and rename it to php.ini

If you do not want to use the MacPorts method to install PHPMcrypt on Mac OS X, you can also opt for building and installing it manually.


Install PHPMcrypt in Mac OS X Yosemite – MacPorts [How To] was originally published on on November 29, 2014 - 6:44 pm (Indian Standard Time)