You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac High Sierra下用Homebrew安装PHP5.6的mcrypt扩展失败求助

Fixing PHP 5.6 mcrypt Installation on macOS (Post-2018)

Hey there, I’ve run into this exact problem before—those old Homebrew formulas for PHP 5.x extensions got retired back in 2018, so the php56-mcrypt command won’t work anymore. Let me walk you through the current, reliable way to get mcrypt up and running with PHP 5.6:

Step 1: Install PHP 5.6 via a Third-Party Tap

Since Homebrew’s core repo no longer supports old PHP versions, use the maintained third-party tap for legacy PHP builds:

  • Add the tap first:
    brew tap shivammathur/php
    
  • Install PHP 5.6:
    brew install shivammathur/php/php@5.6
    
  • Link it to make it your active PHP version (you might need to unlink other PHP versions first with brew unlink php if needed):
    brew link php@5.6 --force
    

Step 2: Install mcrypt via PECL

With PHP 5.6 set up, we’ll use PECL (the PHP Extension Community Library) to install the mcrypt extension:

  • First, install the mcrypt system dependency:
    brew install mcrypt
    
  • Install the compatible mcrypt version for PHP 5.6 (version 1.0.1 is the last one that supports PHP 5.x):
    pecl install mcrypt-1.0.1
    
    When prompted for the mcrypt prefix, just hit enter—it should auto-detect the path from Homebrew.

Step 3: Enable the Extension in php.ini

  • Locate your PHP 5.6 php.ini file (typically at /usr/local/etc/php/5.6/php.ini).
  • Open it in a text editor and add this line at the end:
    extension=mcrypt.so
    
  • Restart your PHP service (e.g., if using php-fpm, run brew services restart php@5.6; if using Apache, restart Apache).

Step 4: Verify the Installation

Run this command to check if mcrypt is loaded:

php -m | grep mcrypt

If you see mcrypt printed out, you’re all set!

Why the Old Method Stopped Working

Back in March 2018, Homebrew deprecated and removed the dedicated PHP tap, which included all the old PHP version formulas and their companion extensions like php56-mcrypt. Legacy PHP support moved to community-maintained taps like the one we used here, and extensions are now installed via PECL instead of dedicated brew formulas.

内容的提问来源于stack exchange,提问作者Jose Rojas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 10:06:17