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

Ubuntu 14.04系统下为PHP 7.1安装phpredis的求助

Getting phpredis Working with PHP 7.1.15 on Ubuntu 14.04

Hey there, let's walk through getting phpredis properly installed and loaded for your setup. First, here's your PHP environment info for reference:

PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:51:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
    with Zend OPcache v7.1.15-1+ubuntu14.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies

You mentioned trying both PECL and manual installs—let's break down the critical steps for each that are easy to overlook, plus some troubleshooting tips.

PECL Installation: Verify Configuration & Loading

You ran sudo pecl install redis and restarted php7.1-fpm, but extensions often fail to load because the PHP config isn't updated. Here's what to check:

  • Add the extension to your PHP configs: After PECL finishes, it usually tells you to add extension=redis.so to your PHP ini files. Run php -i | grep "Loaded Configuration File" to find your CLI php.ini path. For PHP-FPM, look in /etc/php/7.1/fpm/php.ini or the conf.d subdirectory (creating a separate file like /etc/php/7.1/fpm/conf.d/20-redis.ini here is cleaner).
  • Confirm the extension is loaded:
    • For CLI: Run php -m | grep redis—if you see redis printed, it's loaded.
    • For FPM: Create a simple phpinfo.php file with <?php phpinfo(); ?>, host it, and search for "redis" in the output. If it's missing, the FPM config wasn't updated or restarted properly.
  • Check FPM logs: If restarting FPM didn't help, look at /var/log/php7.1-fpm.log for errors about missing redis.so or invalid paths.

Manual Compilation: Fix Common Pitfalls

If the manual install from source didn't work, make sure you're using the correct tools for your PHP 7.1 setup:

  • Install build dependencies first: You'll need development tools for PHP. Run sudo apt-get install php7.1-dev build-essential—this installs phpize, php-config, and compiler tools.
  • Use the correct PHP 7.1 utilities: When compiling, specify the exact phpize and php-config for 7.1 to avoid targeting the wrong PHP version:
    phpize7.1
    ./configure --with-php-config=/usr/bin/php-config7.1
    make && sudo make install
    
  • Same config step as PECL: After compiling and installing, add extension=redis.so to both CLI and FPM configs, then restart FPM.

Troubleshooting Common Issues

  • "redis.so not found" errors: Find your extension directory with php -i | grep extension_dir (it'll look like /usr/lib/php/20160303/ for PHP 7.1). Then update your ini file to use the full path: extension=/usr/lib/php/20160303/redis.so.
  • Deb.sury.org source quirks: Ubuntu 14.04 with the sury repo sometimes has non-standard extension paths—always use php -i to confirm the correct directory instead of guessing.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 08:40:08