I also had this problem in trying to deploy a Laravel
to Apache
on Mac OS Sierra
. I eventually found this post that gave step-by-step instructions to resolve this issue. These instructions assume that you have Homebrew installed; if you don't have it installed, then paste the following into a Terminal window to install it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Here is the relevant steps pasted from the post given above:
Step 1: Install autoconf and mcrypt
I used homebrew to install autoconf and mcrypt, which is as easy as:
brew install autoconf mcrypt
If this does not work for you, or you don't want to use homebrew, then check out this tutorial.
Step 2: Build the PHP extension
To build the PHP extension you will need the PHP 5.4.17 source code that is available for download here and extract it:
cd ~/Downloads
unzip PHP-5.4.17.zip
Then build the extension using the following commands:
cd php-src-PHP-5.4.17/ext/mcrypt/
/usr/bin/phpize
./configure
make
sudo make install
Step 3: Enable the extension
All that is left is to enable the extension by editing /etc/php.ini. If this file is not present, copy /etc/php.ini.default and rename it:
sudo cp /etc/php.ini.default /etc/php.ini
Edit the /etc/php.ini file and add the following:
extension=mcrypt.so
Step 4: Restart apache
Now just restart apache and you're done!
sudo apachectl restart
ADDITIONAL NOTES AND CLARIFICATION
I did encounter two issues with following these steps:
- I had to match the
PHP
zip file that I downloaded to the version of PHP that was installed on my machine.
So I did
php -v
to determine the version number and then changed the download to match that version number. In my case the PHP
version was 5.6.28 and so I needed to download the PHP source from
https://github.com/php/php-src/archive/PHP-5.6.28.zip
- I got an exception at step 2 when I tried to do the
sudo make install
, the exception was caused by SIP, a security featured added by El Capitan
. The exception is outlined in this question, and the resolution to this problem I found in this answer.
Applying the information from this answer changed the step 2 listed above and replaced the sudo make install
with the following:
mkdir -p /usr/local/lib/php/extensions
sudo make EXTENSION_DIR='/usr/local/lib/php/extensions' install
Take note that because of this change, step 4 above also needs to changed to include the path to mcrypt.so
. So the following must go in the php.ini
:
extension=/usr/local/lib/php/extensions/mcrypt.so