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

Ubuntu系统安装php7.0-mcrypt包依赖错误解决求助

Fixing "Unmet Dependencies" for php7.0-mcrypt on Ubuntu

Hey there, let's tackle that frustrating dependency error you're hitting when trying to install php7.0-mcrypt. The root issue is that libmcrypt4 isn't available in Ubuntu's default repositories for most modern releases, plus you might have some broken package states to clean up first. Here's a step-by-step solution:

Step 1: Repair Broken Packages First

Before adding new sources, let's fix any existing broken package states:

  • Update your package list to ensure you have the latest repo info:
    sudo apt update
    
  • Fix any broken dependencies or incomplete installations:
    sudo apt --fix-broken install
    
  • Reconfigure any partially installed packages:
    sudo dpkg --configure -a
    

Step 2: Add a PPA That Provides libmcrypt4

The default Ubuntu repos don't include libmcrypt4 for newer versions, so we'll use the widely trusted Ondřej Surý PHP PPA, which maintains legacy PHP packages and their dependencies:

  • Add the PPA to your system:
    sudo add-apt-repository ppa:ondrej/php
    
  • Update your package list again to pull in the new PPA's packages:
    sudo apt update
    

Step 3: Install php7.0-mcrypt

Now the missing libmcrypt4 dependency should be available. Install the package with:

sudo apt install php7.0-mcrypt

If you still run into issues, try installing the dependency explicitly first:

sudo apt install libmcrypt4 php7.0-mcrypt

Step 4: Verify the Installation

To confirm everything worked, check if the mcrypt extension is loaded in PHP:

php -m | grep mcrypt

You should see mcrypt printed if the installation was successful.

Note for Newer Ubuntu Versions

If you're running Ubuntu 20.04 LTS or later, PHP 7.0 is end-of-life and no longer supported officially. While the PPA above will let you install it, consider upgrading to a supported PHP version (like 7.4, 8.1, or newer) for security and compatibility long-term.

内容的提问来源于stack exchange,提问作者Ganesh Malode

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:34:07