PHP Redis 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11424547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:29:46  来源:igfitidea点击:

PHP redis error

phpredis

提问by user1321109

I installed the php redis extension. But when I run the test code, I got the following error:

我安装了 php redis 扩展。但是当我运行测试代码时,出现以下错误:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/redio.so' - /usr/lib/php5/20090626+lfs/redio.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error:  Class 'Redis' not found in /var/www/test/redisTest.php on line 2

My php version is 5.3.10, I installed the new version of phpredis.

我的php版本是5.3.10,我安装了新版本的phpredis。

May I get your help? THANKS!

我可以得到你的帮助吗?谢谢!

The install steps are:

安装步骤如下:

git clone https://github.com/nicolasff/phpredis.git
cd phpredis
 phpize
make 
make install

Then add a config file in /etc/php5/fpm/confi.d to load redis.so

然后在/etc/php5/fpm/confi.d中添加一个配置文件来加载redis.so

回答by Manu Manjunath

I use PHP 5.3 and installing PHP-Redis using below steps worked just fine for me:

我使用 PHP 5.3 并使用以下步骤安装 PHP-Redis 对我来说效果很好:

  • Install pecl extension
    sudo pecl install redis
  • In php.ini, you mayneed set extension_dirto correct value. (can be usr/lib64/php/modulesas above command placed the redis.so in this directory). In my case, I didn't set this.
  • Add below line to php.ini:
    extension=redis.so
  • Restart Apache/PHP-FPM
  • 安装pecl扩展
    sudo pecl install redis
  • 在 中php.ini,您可能需要设置extension_dir为正确的值。(可以usr/lib64/php/modules按照上面的命令把redis.so放在这个目录下)。就我而言,我没有设置这个。
  • 将下面的行添加到php.ini
    extension=redis.so
  • 重启 Apache/PHP-FPM

回答by Jai Prakash

To verify if you have got redis installed you can do this

要验证您是否安装了 redis,您可以执行此操作

php -m | grep redis

php -m | grep redis

回答by Hammo

Create a file PHP with echo phpinfo();in it and see if the module is showing up. If you do not see the module then it is not being loaded correctly.

使用echo phpinfo()创建一个 PHP 文件在里面,看看模块是否出现。如果您没有看到该模块,则说明它没有被正确加载。

回答by Claudionor Oliveira

In the PHP5.3 and Amazon Linux AMI (Same as Centos OS 5)

在 PHP5.3 和 Amazon Linux AMI 中(与 Centos OS 5 相同)

install libs

安装库

yum install php-pear php-devel make gcc wget

install redis

安装redis

cd /opt/
mkdir /opt/redis
wget https://redis.googlecode.com/files/redis-2.6.14.tar.gz "or last version"
tar -zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make
make install

install php-redis by pecl

通过 pecl 安装 php-redis

pecl install redis

configuration option "php_ini" is not set to php.ini location

配置选项“php_ini”未设置为 php.ini 位置

You should add "extension=redis.so" to php.ini

您应该将“extension=redis.so”添加到 php.ini

reload the web service httpd

重新加载 Web 服务 httpd

service httpd reload

verify that the extension has been installed

验证扩展是否已安装

php -m
[PHP Modules]
bz2
...
**redis**
...
[Zend Modules]

回答by Kiran Maniya

Download the proper library file according to your server environment( ex. x86). also, check for your PHP is thread-safe or not and download the Redis library accordingly. then place the library file inside the extension folder. you need to mention the library inside your php.ini as given below.

根据您的服务器环境(例如 x86)下载适当的库文件。此外,检查您的 PHP 是否线程安全并相应地下载 Redis 库。然后将库文件放在扩展文件夹中。您需要在 php.ini 中提及该库,如下所示。

extension=redis.dll

then restart the server once, and check it's working properly or not. if you have command line PHP, you can check it in the command line PHP as,

然后重新启动服务器一次,并检查它是否正常工作。如果你有命令行 PHP,你可以在命令行 PHP 中检查它,

php r("print_r(get_loaded_extensions());")