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

谷歌云Compute Engine安装Mcrypt扩展后仍报错求助

Troubleshooting "The Encrypt library requires the Mcrypt extension" in CodeIgniter 3 on GCE

Hey there, I’ve dealt with this exact headache a few times when working with older CodeIgniter versions and PHP 7.0. Let’s walk through the fixes step by step:

  • Verify if Mcrypt is actually enabled
    Installing the package doesn’t always mean it’s loaded by PHP. Run this terminal command to check your CLI PHP setup:

    php -m | grep mcrypt
    

    If "mcrypt" doesn’t show up, the extension isn’t enabled. Also, create a quick phpinfo.php file in your web root:

    <?php phpinfo(); ?>
    

    Access it via your browser and search for "mcrypt"—if it’s missing, your web server’s PHP config is using a different ini file than the CLI version, and the extension isn’t loaded there.

  • Manually enable the Mcrypt extension
    First, find your PHP 7.0 configuration file path:

    php --ini
    

    Look for the "Loaded Configuration File" line. Open that file with a text editor (like nano):

    sudo nano /path/to/your/php.ini
    

    Search for a line like ;extension=mcrypt.so (the semicolon means it’s commented out). Remove the semicolon to uncomment it, save the file, and exit.

  • Restart the correct service (not just the instance)
    Restarting your GCE instance doesn’t always trigger a reload of PHP or your web server. Use the right command for your setup:

    • For Apache:
      sudo systemctl restart apache2
      
    • For Nginx + PHP-FPM:
      sudo systemctl restart php7.0-fpm
      sudo systemctl restart nginx
      

    This ensures the updated PHP config takes effect.

  • Alternative: Switch to OpenSSL (more future-proof)
    Mcrypt is deprecated in PHP 7.1+ and removed in later versions, so switching to OpenSSL is a smarter long-term fix. In your CodeIgniter application/config/config.php:

    $config['encryption_driver'] = 'openssl';
    

    Confirm OpenSSL is enabled with php -m | grep openssl—it’s usually enabled by default in PHP 7.0.

After trying these steps, reload your CodeIgniter site—this should resolve the error.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 07:13:25