Get PHP and mcrypt working on MacOS

Having trouble getting mcrypt working with PHP on MacOS, maybe even with Zend Server? Getting an error something like this:

dlopen(/usr/local/zend/lib/php_extensions/, 9): Library not loaded: /usr/lib/libltdl.3.dylib

Note: Brew is going to compile some stuff so you are going to need to install XCode before you attempt this process.

Here is the fix. First, install Brew if you haven’t. Then use it to install mcrypt:

brew install mcrypt
brew install mcrypt

Once mcrypt is installed, link the library up to where php expects to find it:

sudo ln -s /usr/lib/libltdl.7.dylib /usr/lib/libltdl.3.dylib
sudo ln -s /usr/lib/libltdl.7.dylib /usr/lib/libltdl.3.dylib

Restart apache or run your PHP script and you should be good to go!

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">