So macOS High Sierra 10.13 now comes with PHP 7.1. While configuring Apache I also created a new /etc/php.ini from the /etc/php.ini.default file, made sure to check that is was being loaded by PHP after restarting Apache, however the version of Xdebug extension that ships with macOS 10.13 doesn't seem to load or show up when you run phpinfo();
My php.ini is definitely being loaded:
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Here's what my /etc/php.ini looks like where I configure Xdebug:
[xdebug]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
[Update, fixed that typo here...]
However, Xdebug doesn't load and checking php -i give no results:
$php -i | grep xdebug
PHP Warning: Method xdebug_start_function_monitor() cannot be a NULL
function in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
Segmentation fault: 11
And yes, the path to the file is correct:
$ ls /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so*
This used to work on PHP 5 so I hope someone can help me and anyone else in future struggling with this issue.
When I check my apache log I get the following error:
Failed loading /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so: dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, 9): Symbol not found: _xdebug_monitored_function_dtor
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Expected in: flat namespace
in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
I'm not making progress in terms of find out how I can resolve this error:
Symbol not found: _xdebug_monitored_function_dtor
Ok so I finally got it running myself it works perfectly! I'm assuming that the xdebug binary that comes with macOS High Sierra (found under: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so) is not compatible with PHP7's new Zend engine.
So I downloaded the latest source from the xdebug website and did the following:
Installed autoconf with brew;
Run phpize to configure the build for the new Zend engine;
Run ./configure
Run make
Now the new binary is under modules/xdebug.so
However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/. I didn't want to disable this so I created a new directory path under /usr/local/lib/php/extensions/ and copied the new binary to this location. I'm not sure if this directory is the best place to put it or if this is bad practice but it worked for me.
Finally I reconfigured my php.ini to use the new binary and everything worked perfectly!
In order to install it you have to have xcode command line tools.
So you need to run:
xcode-select --install
Then you need to install autoconf:
brew install autoconf
Then you have to download the code from here.
After that you have to run in the folder of the source code:
phpize
./configure
make
sudo cp modules/xdebug.so /usr/local/php/extensions (if the directory doesn't exist go and create it)
And finally inside php.ini add
zend_extension=/usr/local/php/extensions/xdebug.so
After that you can enable xdebug inside php.ini and restart apache
sudo apachectl restart
you made a typo in "zend_extention". this should be zend_extension.
and i think the full path is unnecessary
zend_extension=xdebug.so
should be enough
If you have brew installed with multiple PHP versions i.e. 7.1, 7.2 and 7.3 on Mac OS X mojave, you can to do the following:
Install autoconf with brew brew install autoconf.
Change to the PHP version that you want Xdebug on, run brew unlink php#7.1 && brew link --force --overwrite php. This will switch from PHP 7.1 to PHP 7.3.
Download the latest Xdebug source from xdebug website.
Extract the Xdebug tar and navigate to extracted directory, where you'd see all the files.
Run phpize to configure the build for the new Zend engine.
Run ./configure.
Run make.
Xdebug extension xdebug.so gets compiled in modules directory.
Create a new directory path under /usr/local/lib/php/7.3.1/extensions/ and copy xdebug.so to this location. Here, 7.3.1 is the current version that I switched earlier, change this to match your PHP version.
Open php.ini in an editor and enter
zend_extension="/usr/local/lib/php/7.3.1/extensions/xdebug.so" then save the change.
Run php -v and it will show Xdebug has been configured correctly.
If you want to configure Xdebug on another PHP version then just repeat from step 2 all the way to 11. As mentioned in earlier post, this way you don't need to disable/enable System Integrity Protection on Mac OS X.
For anyone arriving late at this party, the initial attempt in the question seems to work just fine in macOS 10.13.6
Hello for everyone that got error trying to install xDebug on Mac.
error: unknown type name 'uint64_t'
There are files in your local/bin/include that causes this error. By removing them you get rid of the error. Though, you might have to reinsatall brew.
https://github.com/cython/cython/issues/2009
I've just installed the latest XAMPP for PHP 5.6 from the official website, and I need to enable Xdebug, I find that the file php_xdebug.dll exists in the C:\xampp\php\ext , but there is no [XDebug] config at all in the php.ini and I have no idea how to make it work. It should be installed by default and pre-configured, we need just to uncomment the xdebug config in php.ini but it's not the case. I even tried to install it again using PECL commmand pecl install xdebug but I get the following error :
pecl install xdebug
downloading xdebug-2.5.0.tgz ...
Starting to download xdebug-2.5.0.tgz (267,640 bytes)
.........done: 267,640 bytes
ERROR: failed to mkdir C:\php\pear\docs\xdebug\contrib
And in PHPStorm when I choose to add the interpreter by selecting the php.exe in the XAMPP directory, it says Debugger : Not installed too.
I re-installed XAMPP, but I still have the same problem.
Thanks in advance.
For more details, you can find a tutorial that explains step by step procedure
php-debugging-with-xdebug-atom-and-xampp
As per this tutorial please follow these steps its works like a charm:
Steps to Install Xdebug:
Download xdebug-2.4.0.tgz
Unpack the downloaded file
# navigate to the downloaded file
$ cd ~/Downloads
$ tar -xvzf xdebug-2.4.0.tgz
$ cd xdebug-2.4.0
run phpize
$ phpize
# example output
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
#Error possibilty
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
#In the above error case you need to install autoconf using below command(MAC) and rerun phpize
$ brew install autoconf
The phpsize command is used to prepare the build environment for a
PHP extension.
Configure it by run:
$ ./configure
run make
$ make
A successful install will have created xdebug.so file.
Steps to Configure Xdebug:
A successful install will have created xdebug.so and put it into the PHP extensions directory.
You must copy this file to XAMPP php extension directory for that
run:-
$ sudo cp modules/xdebug.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303
Finally update /Applications/XAMPP/xamppfiles/etc/php.ini and add
the following lines to it
[Xdebug]
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=On
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
Restart Apache using XAMPP’s manager-osx
Congratz! You have completed!! To verify you successfully installed & configured XDebug, open the XAMPP phpinfo.php file in a web browser, for example, http://localhost/dashboard/phpinfo.php.
Search for XDebug section in PHPInfo details. If it exists, you successfully have done your installation
OR
In another browser window or tab, open https://xdebug.org/wizard.php and copy the phpinfo.php page content in the first window or tab and paste it into the textbox on the xdebug.org page. Then submit for analysis, it will give a summary of your installation status.
Safest was is to use XDebug wizard that will give you step by step instructions on how to install on your own machine. Then update your php.ini (tune to your needs)
Note: Wizard will give you instructions for what SAPI it receives phpinfo() contents from. So if you fill CLI phpinfo() output you will get instructions for your PHP CLI. If you paste phpinfo() from a server page you will get instructions for that.
First copy your phpinfor() content form. paste the [xdebug wizard][1] [1]: https://xdebug.org/wizard. then download the xdebug.dll. after that follow this steps
Remove the exists php_xdebug.dill and paste the xampp\php\ext\php_xdebug.dll
update the php.ini like this
[Xdebug] zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=1 debug.remote_autostart=true
I found a solution for xdebug not working even after xdebug has been installed in NetBeans +xampp here. The idea is you have to use all the settings for php.ini mentioned here and not just the usual ones mentioned in forums.
I am searching the way to debug php scripts. In internet i found information that i can do that with MacGDBp + XDebug.
When i'm trying install using PECL in Shell:
sudo pecl install xdebug
The next error have been occured:
downloading xdebug-2.4.0.tgz ...
Starting to download xdebug-2.4.0.tgz (264,832 bytes)
.....................done: 264,832 bytes
76 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
Help me find the way to solve that problem.
XDebug is available by default. Just enable it by
1) sudo nano /etc/php.ini (or sudo cp /etc/php.ini.default /etc/php.ini first if the file doesn't yet exist)
2) Add these lines at the end (verify the path with ls ls /usr/lib/php/extensions/)
[Xdebug]
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
3) Restart apache using sudo apachectl restart
4) Verify by php -m | grep xdebug
Mike Chamberlain's excellent response almost got xdebug working with NetBeans using Mac OS Sierra 10.12. Only two changes required:
In step 2, after
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
also add
xdebug.remote_enable=1
This was necessary because the precompiled .so file has xdebug remote access disabled. NetBeans and other tools need it to be enabled.
For debugging using xdebug i used the following steps
For installing php72 I installed using brew with the following command:
brew install homebrew/php/php72-xdebug
I added the following command to the bottom of the php.ini file:
zend_extension=/usr/local/Cellar/php72-xdebug/2.6.0/xdebug.so
Note: if you need to search for a version of xdebug with brew use:
brew search xdebug
I'm trying to get pthreads running on my Ubuntu-Server (14.04) after I installed Apache2 and PHP5 via apt-get.
My initial steps:
installed apache2 - apt-get install apache2
installed php5 with the usual modules apt-get install php5 libapache2-mod-php5 php5-mcrypt ...
Then i followed this tutorial to get pthreads running (User contributed manual on php.net):
1 - Get PHP version
For this example we will use version: 5.4.36
# wget http://www.php.net/distributions/php-5.4.36.tar.gz
2- Get Pthreads version:
I'm using an old version but, you could take any on
# wget http://pecl.php.net/get/pthreads-1.0.0.tgz
Extract both, php and pthreads versions
#tar zxvf php-5.4.36.tar.gz
#tar zxvf pthreads-1.0.0.tgz
3- Move Pthreads to php/ext folder. Inside version of PHP downloaded at item 1.
4- Reconfigure sources
# ./buildconf --force
# ./configure --help | grep pthreads
You have to see --enable-pthreads listed. If do not, clear the buidls with this commands:
# rm -rf aclocal.m4
# rm -rf autom4te.cache/
# ./buildconf --force
5 - Inside php folder run configure command to set what we need:
# ./configure --enable-debug --enable-maintainer-zts --enable-pthreads
--prefix=/usr --with-config-file-path=/etc
6 - Install PHP
We will run make clear just to be sure that no other crashed build will mess our new one.
# make clear
# make
# make install
7 - Copy configuration file of PHP and add local lib to include path
# cp php.ini-development /etc/php.ini
Edit php.ini and set Include_path to be like this:
Include_path = “/usr/local/lib/php”
9 - Check Modules
# php -m (check pthread loaded)
You have to see pthreads listed
10 - If pthread is not listed, update php.ini
# echo "extension=pthreads.so" >> /etc/php.ini
Everything works fine until step 7.
There is a new directory (seems to be the make install - outcome) in /usr/lib/php .
Now i don't know how to handle with replacing the existing php-installation with my new one.
Where do i have to copy the php.ini-development from step 7?
I tried cp php.ini-development /etc/php.ini
but it had no effect on my existing installation.
How can i get my new-compiled php working in / with apache2?
I found three php.ini-files from the initial installation on my server:
/etc/php5/apache2/php.ini
/etc/php5/fpm/php.ini
/etc/php5/cli/php.ini
Create a file in your webserver's root folder (or any folder that you can easily access from a browser). Inside the file write the following and save it as phpinfo.php:
<?php phpinfo(); ?>
When you access the file from a browser, you will see the configuration of the php engine that parsed the file. Somewhere there is the path to your php.ini file, the one you need to modify.
Usually, if you are using mod_php5 then your php.ini SHOULD be the one located under the apache2 folder; if you are using php-fpm then it should be the one under fpm, but the only certain way to know which one you are using is to issue a phpinfo().
Apologies in advance for the potential n00b questions, I am trying to install the mcrypt extension for PHP on my OSX Mountain Lion machine.
The following steps in terminal is what I have done so far to achieve my PHP install
cd /path/to/downloaded/php-5.3.21/ext/mcrypt/
/usr/bin/phpize
./configure
cd /path/to/downloaded/php-5.3.21
./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs
make
sudo make install
Which seems to work well and installs PHP 5.3.21 fine. I have then done
sudo nano /private/etc/php.ini
And included
extension=mcrypt.so
Along with an Apache restart, phpinfo() doesn't show that the mcrypt extension is loaded.
I then tried to specify the extension_dir inside php.ini, again with no luck.
I have done
locate mcrypt.so
/opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so
/usr/local/Cellar/php53-mcrypt/5.3.18/mcrypt.so
And tried both directories as the extension_dir, with no luck.
I have also tried the following, after much Googling
./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs --with-mcrypt
Which seems to work OK, but then upon "make", it returns
ext/mcrypt/mcrypt.o: No such file or directory
ext/mcrypt/mcrypt_filter.o: No such file or directory
Again, no success.
What am I doing wrong? It seems like the physical compile of mcrypt.so is not happening, or is compiling incorrectly as I would suspect there to be another mcrypt.so found under locate?
Anyone please help? I've gone through pages upon pages of Google searches with no luck!
I tend to use Homebrew on Mac. It will install and configure all the stuff for you.
Link
Then you should be able to install it with brew install mcrypt php53-mcrypt and it'll Just Work (tm).
You can replace the 53 with whatever version of PHP you're using, such as php56-mcrypt or php70-mcrypt. If you're not sure, use brew search php.
Do also remember that if you are using the built in Mac PHP it's installed into /usr/bin you can see which php you are using with which php at the terminal and it'll return the path.
I just went through this on Mountain Lion. Homebrew blocked on libiconv which it thought was missing but was actually up to date. After an hour of trying to get it to recognize libiconv, I gave up and installed it the old fashion way, which took all of five minutes...
(download your php version)
$ wget http://www.php.net/get/php-5.3.21.tar.gz/from/a/mirror
$ tar -xvzf php-5.3.21.tar.gz
$ cd php-5.3.21/ext/mcrypt
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install
mcrypt.so is now in your PHP ext dir (/usr/lib/php/extensions/no-debug-non-zts-20090626/ in my case), now you need to add to php.ini as a module
$ vi /etc/php.ini
$ (insert) extension=mcrypt.so
$ sudo apachectl restart
Done - no brew necessary. HTH someone.
Installing php-mcrypt without the use of port or brew
Note: these instructions are long because they intend to be thorough. The process is actually fairly straight-forward. If you're an
optimist, you can skip down to the building the mcrypt extension
section, but you may very well see the errors I did, telling me to
install autoconf and libmcrypt first.
I have just gone through this on a fresh install of OSX 10.9. The solution which worked for me was very close to that of ckm - I am including their steps as well as my own in full, for completeness. My main goal (other than "having mcrypt") was to perform the installation in a way which left the least impact on the system as a whole. That means doing things manually (no port, no brew)
To do things manually, you will first need a couple of dependencies: one for building PHP modules, and another for mcrypt specifically. These are autoconf and libmcrypt, either of which you might have already, but neither of which you will have on a fresh install of OSX 10.9.
autoconf
Autoconf (for lack of a better description) is used to tell not-quite-disparate, but still very different, systems how to compile things. It allows you to use the same set of basic commands to build modules on Linux as you would on OSX, for example, despite their different file-system hierarchies, etc. I used the method described by Ares on StackOverflow, which I will reproduce here for completeness. This one is very straight-forward:
$ mkdir -p ~/mcrypt/dependencies/autoconf
$ cd ~/mcrypt/dependencies/autoconf
$ curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
$ tar xzf autoconf-latest.tar.gz
$ cd autoconf-*/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
Next, verify the installation by running:
$ which autoconf
which should return /usr/local/bin/autoconf
libmcrypt
Next, you will need libmcrypt, used to provide the guts of the mcrypt extension (the extension itself being a provision of a PHP interface into this library). The method I used was based on the one described here, but I have attempted to simplify things as best I can:
First, download the libmcrypt source, available from SourceForge, and available as of the time of this writing, specifically, at:
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
You'll need to jump through the standard SourceForge hoops to get at the real download link, but once you have it, you can pass it in to something like this:
$ mkdir -p ~/mcrypt/dependencies/libmcrypt
$ cd ~/mcrypt/dependencies/libmcrypt
$ curl -L -o libmcrypt.tar.bz2 '<SourceForge direct link URL>'
$ tar xjf libmcrypt.tar.bz2
$ cd libmcrypt-*/
$ ./configure
$ make
$ sudo make install
The only way I know of to verify that this has worked is via the ./configure step for the mcrypt extension itself (below)
building the mcrypt extension
This is our actual goal. Hopefully the brief stint into dependency hell is over now.
First, we're going to need to get the source code for the mcrypt extension. This is most-readily available buried within the source code for all of PHP. So: determine what version of the PHP source code you need.
$ php --version # to get your PHP version
now, if you're lucky, your current version will be available for download from the main mirrors. If it is, you can type something like:
$ mkdir -p ~/mcrypt/php
$ cd ~/mcrypt/php
$ curl -L -o php-5.4.17.tar.bz2 http://www.php.net/get/php-5.4.17.tar.bz2/from/a/mirror
Unfortunately, my current version (5.4.17, in this case) was not available, so I needed to use the alternative/historical links at http://downloads.php.net/stas/ (also an official PHP download site). For these, you can use something like:
$ mkdir -p ~/mcrypt/php
$ cd ~/mcrypt/php
$ curl -LO http://downloads.php.net/stas/php-5.4.17.tar.bz2
Again, based on your current version.
Once you have it, (and all the dependencies, from above), you can get to the main process of actually building/installing the module.
$ cd ~/mcrypt/php
$ tar xjf php-*.tar.bz2
$ cd php-*/ext/mcrypt
$ phpize
$ ./configure # this is the step which fails without the above dependencies
$ make
$ make test
$ sudo make install
In theory, mcrypt.so is now in your PHP extension directory. Next, we need to tell PHP about it.
configuring the mcrypt extension
Your php.ini file needs to be told to load mcrypt. By default in OSX 10.9, it actually has mcrypt-specific configuration information, but it doesn't actually activate mcrypt unless you tell it to.
The php.ini file does not, by default, exist. Instead, the file /private/etc/php.ini.default lists the default configuration, and can be used as a good template for creating the "true" php.ini, if it does not already exist.
To determine whether php.ini already exists, run:
$ ls /private/etc/php.ini
If there is a result, it already exists, and you should skip the next command.
To create the php.ini file, run:
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
Next, you need to add the line:
extension=mcrypt.so
Somewhere in the file. I would recommend searching the file for ;extension=, and adding it immediately prior to the first occurrence.
Once this is done, the installation and configuration is complete. You can verify that this has worked by running:
php -m | grep mcrypt
Which should output "mcrypt", and nothing else.
If your use of PHP relies on Apache's httpd, you will need to restart it before you will notice the changes on the web. You can do so via:
$ sudo apachectl restart
And you're done.
Why You're Getting This Error
PHP complains if one of the files like mcrypt.so is included using the syntax extension="mcrypt.so" but the file is not in the extension_dir path ( use <?php phpinfo(); ?> or php -i to check that).
It will also tell you which php.ini config file is being loaded so you will know where the settings are coming from. Most likely it will be something like /usr/local/etc/php/5.4/php.ini if you are using the homebrew version.
Take note of the part under it that says something like "Scan this dir for additional .ini files" because what that means is it gives you a place to put your own file, like tweaks.ini that is loaded after the main configuration file so that you can make changes and keep up with them easily. Also remember that all the files in this directory get loaded in alphabetical order, so if you have one called adjustments.ini that contains mcrypt directives, and there is a mcrypt.ini, most likely your settings will be overridden.
One alternative to specifying extension="mcrypt.so" is to specify the full path to the mcrypt.so file. The other option is to edit the extension_dir setting.
What worked for me
On Mavericks I didn't have to do either. I did a fresh install of homebrew and then added the josegonzalez tap using:
brew tap josegonzalez/homebrew-php
(My other laptop was running Mountain Lion and was also using homebrew in this setup.)
After you've tapped that awesome repo you can install php and mcrypt using something like:
brew install php54 php54-mcrypt
What if this doesn't work (and why should I use homebrew anyway?)
I would highly advise trying this route before downloading and building it from source. It's not hard to build from source - but I don't want to have to maintain that. It's one of the reasons to use homebrew in the first place - it's a package manager (with a HUGE community).
There is a lot of development on the homebrew project and - if you have problems I'd suggest checking out their issues page
So yes you can build it from source and that might seem like a good option right now if you just want mcrypt to work but you may hate yourself for doing this later...
If you don't want to be using php54 there is also the php53 branch. They have some instructions at the repo about how to use both of them / switch between them.
If you're new to homebrew you should know that you check out what else is available using brew search php54, which gives something like:
php54 php54-lzf php54-snappy
php54-amqp php54-mailparse php54-solr
php54-apc php54-mcrypt php54-ssh2
php54-apcu php54-memcache php54-stats
php54-boxwood php54-memcached php54-svm
php54-chdb php54-midgard2 php54-tidy
php54-couchbase php54-mongo php54-timezonedb
php54-dbase php54-msgpack php54-tokyotyrant
php54-ev php54-mysqlnd_ms php54-twig
php54-gearman php54-oauth php54-uploadprogress
php54-geoip php54-opcache php54-uuid
php54-gmagick php54-parsekit php54-varnish
php54-graphdat php54-pcntl php54-wbxml
php54-http php54-pdflib php54-xcache
php54-igbinary php54-phalcon php54-xdebug
php54-imagick php54-proctitle php54-xhgui
php54-inclued php54-pspell php54-xhp
php54-intl php54-pthreads php54-xhprof
php54-ioncubeloader php54-raphf php54-xmldiff
php54-jsmin php54-redis php54-yac
php54-judy php54-riak php54-yaf
php54-leveldb php54-runkit php54-yaml
php54-libevent php54-scrypt php54-yaz
php54-libvirt
TLDR
You should use homebrew to install mcrypt if at all possible
If you're getting errors it's probably because your configuration file(s) are messed up. Check the extension_dir path and figure out where the mcrypt.so file is and see if there is a discrepancy (or specify the full path)
For me, on Yosemite
$ brew install mcrypt php56-mcrypt
restart computer
did the trick.
Solution with brew worked only after the following:
in your php.ini
nano /private/etc/php.ini
add this line:
extension="/usr/local/Cellar/php53-mcrypt/5.3.26/mcrypt.so"
Warning! Set the correct PHP version.
I would recommend installing everything via homebrew if you have the option. I went in circles for a while, but installing php 5.x via brew and then the neccessary modules worked a treat. I was working with php 5.4 and used this to get going initially:
https://github.com/josegonzalez/homebrew-php
and then installed the additional modules with:
brew install php54-redis
brew install php54-xdebug
brew install php54-mcrypt
...
Another possibility for those who want to keep OS X as clean as possible, is to use vagrant [1] to define a php development environment. Vagrant can use VirtualBox [2] in headless mode (~3% of CPU on my 13-inch, Mid 2009 MacBook Pro) to run a virtual machine with the webserver and php and all.
To easily create the vagrant environment you can use this great tool https://puphpet.com/
http://www.vagrantup.com/
https://www.virtualbox.org/
I'd create a shell script to install mcrypt module for PHP 5.3 without homebrew.
The scripts install php autoconf if needed and compile module for your php version.
The link is here: https://gist.github.com/lucasgameiro/8730619
Thanks
Nothing worked and finally got it working using resource #Here and Here; Just remember for OSX Mavericks (10.9) should use PHP 5.4.17 or Stable PHP 5.4.22 source to compile mcrypt. Php Source 5.4.22 here
Brew base solution worked for me
Install these packages
$brew install brew install mcrypt php54-mcrypt
Copy default php.ini.default to php.ini
$sudo cp /private/etc/php.ini.default /private/etc/php.ini
Add this line to php.ini file extension section - please verify extension path with install location in your machine
extension="/usr/local/Cellar/php54-mcrypt/5.3.26/mcrypt.so"
Restart your apache server
$apache restart
This is what I did:
$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ tar xzvf libmcrypt-2.5.8.tar.gz
$ ./configure
$ make
$ sudo make install
$ brew install autoconf
$ wget file:///Users/rmatikolai/Downloads/php-5.4.24.tar.bz2
$ tar xjvf php-5.4.24.tar.bz2
$ cd php-5.4.24/ext/mcrypt
$ phpize
$ ./configure # this is the step which fails without the above dependencies
$ make
$ make test
$ sudo make install
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
$ sudo vi /private/etc/php.ini
Next, you need to add the line:
extension=mcrypt.so
$ sudo apachectl restart
mycrypt.o and mcrypt_filter.o are in the ext/.libs of your php downloaded directory. Just copy the files to ext/mcrypt, then run make && make install again.
With recent changes in brew (deprecation of homebrew/php) you now install php with mcrypt with the following.
brew install php#5.6 -with-mcrypt=mcrypt
You may have to uninstall previous installs of php
So after running brew install mcrypt php, I had to install php-mcrypt via pecl:
pecl install mcrypt-1.0.1
At the time of writing, mcrypt does not have a stable pecl release, 1.0.1 being the current release for php 7.2 and 7.3, and brew install php will install php 7.2.
sudo apt-get install php5-mcrypt
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/fpm/conf.d/mcrypt.ini
service php5-fpm restart
service nginx restart