Install mcrypt for php on macos high sierra for a Development Server
Date Posted: 05-02-2018
In this post, we will explain how to install mcrypt for php on mac os high sierra for a Development Server.
Step 1: Search the package:
brew search mcrypt
Result:
==> Searching local taps... homebrew/php/php71-mcrypt mcrypt homebrew/php/php53-mcrypt homebrew/php/php54-mcrypt homebrew/php/php55-mcrypt homebrew/php/php56-mcrypt homebrew/php/php70-mcrypt libtomcrypt
Step 2: Search my php version to know what can I need to install:
php --version
Result:
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Step 3: Install the correct package, for me was 7.1.7 => homebrew/php/php71-mcrypt
brew install homebrew/php/php71-mcrypt
Step 4: Find the find “mcrypt.so” extension file
find /usr/ -type f -name "mcrypt.so"
Result:
find: /usr//local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so
Step 5: Search the php.ini
php -i | grep 'Configuration File'
Result (if exist):
Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini
Step 6: Add the next line at the end on /etc/php.ini (see the last step your correct path) the extension mcrypt.so
extension=/usr/local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so
If there is no php.ini file, then you need to make one from php.ini.default in the same location like so: If the php.ini does not exist in etc folder please follow below steps.
sudo cp /etc/php.ini.default /etc/php.ini
Step 7: And allow write capability
sudo chmod u+w /etc/php.ini
Step 8: Please find the mcrypt.so path and add into php.ini file
Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini
Step 9: Restart the apachectl
That’s it, create a php page with the function phpinfo(); to see if it loaded correctly.
Appreciate!!!
Thats a really nice post, but step 3 dows not work. Homebrew ginds norhing..
Same as Jonas. brew says:
Error: No available formula with the name “homebrew/php/php71-mcrypt”