Skip to content

Instantly share code, notes, and snippets.

@ivmelo
Last active December 7, 2015 15:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivmelo/1af5d627d1a9743e58e3 to your computer and use it in GitHub Desktop.
Save ivmelo/1af5d627d1a9743e58e3 to your computer and use it in GitHub Desktop.
Installing mcrypt extesion on OS X Yosemite

Installing Mcrypt on OS X Yosemite

Installing the mcrypt extension for PHP on OSX Yosemite can be a real headache. I've tried several differents ways and this was the only one that really worked with no errors. If you are having trouble just like I was, try these steps and hopefully it will work for you.

First of all, you will need Xcode and the Xcode Command Line Tools installed on your machine. If you don’t have them, download Xcode from the AppStore, if you already have Xcode installed, you can run

$ xcode-select —install

to install the command line tools. You’ll get a message if you already have it installed.

Once you’re done with xcode, you can move on to the next steps.

1 - Check your php version

$ php -v

It will return something like this:

PHP 5.5.14 (cli) (built: Sep  9 2014 19:09:25) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

In this case, we're using PHP 5.5.14

2 - Download the source code of the PHP version you're using from the following link

$ wget http://www.php.net/get/php-5.5.14.tar.bz2/from/a/mirror

Where you replace the numbers 5.5.14 with your php version as shown in the previous step.

You can also copy and paste the link above on your browser.

3 - Unzip the code you've just downloaded. You can either use

$ tar -xvzf php-5.5.14.tar.bz2

or use a graphic tool

4 - Cd into the folder where mcrypt's source code is located

$ cd php-5.5.14/ext/mcrypt

5 - Run the following commands to compile, test and install mcrypt

$ phpize
$ ./configure
$ make
$ make test
$ sudo make install

6 - If everything went as expected, you already have mcrypt installed. Now you just need to load the module. Open the php.ini file located at

$ nano /etc/php.ini

and add the following line to the file

extension=mcrypt.so

don’t forget to save the file.

Once you’ve done that, you just need to run

$ sudo apachectl restart

and you should be good to go.

To verify if mcrypt is loaded correctly, you can run the following command

$ php -m

And you should find mcrypt in the list of loaded modules.

That’s all. I hope it worked for you.

@ramon-villain
Copy link

$ tar -xvzf php-5.5.14.tar.bz2

no?

@ivmelo
Copy link
Author

ivmelo commented Dec 7, 2015

Fixed! thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment