Mcrypt PHP extension required on Mac OS X Mojave

左心房为你撑大大i 提交于 2020-01-02 20:24:08

问题


I just update my to Mac OS X Mojave. My local site now stop loading.

I kept getting

Mcrypt PHP extension required.

I tried

brew update
brew upgrade
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54-mcrypt
php --version // To Test your php 

I got

Error: php54-mcrypt: cannot load such file -- /usr/local/opt/php54-mcrypt/Abstract/abstract-php-extension

I tried reload my site

I still get this

Mcrypt PHP extension required.


My set up details

php --version , I got

PHP 7.1.4 (cli) (built: May  6 2017 10:02:00) ( NTS )                            
Copyright (c) 1997-2017 The PHP Group                                            
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies                    
    with Zend OPcache v7.1.4, Copyright (c) 1999-2017, by Zend Technologies      

which php, I got

/usr/local/php5/bin/php                                                          

php -i | grep php.ini, I got

Configuration File (php.ini) Path => /usr/local/php5/lib                        
Loaded Configuration File => /usr/local/php5/lib/php.ini 

printenv, I got

TERM=xterm-256color
SHELL=/bin/bash
CLICOLOR=1
TMPDIR=/var/folders/54/y_678c6n7q7_pgk1v5lkzwnr0000gp/T/
SSH_CLIENT=10.20.100.88 49732 22
OLDPWD=/Users/bheng
SSH_TTY=/dev/ttys016
USER=bheng
LSCOLORS=ExFxBxDxCxegedabagacad
MAIL=/var/mail/bheng
PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/opt/curl/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/sbin:/usr/local/php5/bin:/Users/bheng/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/pgsql/bin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/mysql/bin
PWD=/Users/bheng/Desktop
SHLVL=1
HOME=/Users/bheng
GREP_OPTIONS=--color=always
LOGNAME=bheng

How would one go about debugging this further?

SSH_CONNECTION=10.20.100.88 49732 10.20.100.88 22
_=/usr/bin/printenv

When I open up php.info I see this


回答1:


Homebrew made some changes lately regarding PHP and its extensions. Before you had to tap homebrew/php and install a specific PHP version with brew install php71 and a module with brew install php71-mcrypt. Now you have to use php@7.1 and build the extensions yourself using PECL.

Since you have so many different PHP version I suggest to get rid of them all. The following steps will remove all old PHP version from your system:

# Will show you any php packages you've got. make not of that!
brew list | grep php

# Will uninstall any php packages you may have
brew list | grep php | while read x; do brew uninstall --force $x; done

# You may need to run this too
rm -rf /usr/local/Cellar/php

# Clean up Launch Agents
rm ~/Library/LaunchAgents/homebrew.mxcl.php*
sudo rm /Library/LaunchDaemons/homebrew.mxcl.php*
brew untap homebrew/php
brew cleanup
brew update
brew doctor # just to make sure you're all clean
ps ax | grep php
# if some PHP daemons are still runing, reboot.

After the reboot you can install PHP the new way:

brew install php // This installs the latest version. If you need PHP7.1 use brew install php@7.1

Check if this worked:

php --version

The following important paths are:

  • /usr/local/opt/php/lib/httpd/modules/libphp7.so — your apache module.
  • /usr/local/bin/php — your command line PHP.
  • /usr/local/sbin/php-fpm — your PHP-FPM binary.

To install extensions, you have to use pecl:

pecl install mcrypt // Install all other extensions this way 

The extension will be installed to /usr/local/lib/php/pecl/20170718/.

If you use Apache you have to load the Apache module. Edit /usr/local/etc/httpd/httpd.conf and search for the section where all the modules are loaded. Add this line at the end of the section:

LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so

Restart your Apache server and check if the correct PHP version is used.



来源:https://stackoverflow.com/questions/54028143/mcrypt-php-extension-required-on-mac-os-x-mojave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!