Install PHPMcrypt on Mac

PHP

Posted on 2015-04-16 08:14:32


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

2. After this is done, head over to https://www.macports.org/install.php 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.

extension=/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/mcrypt.so

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