In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
How to fix PHP redis502 error? The content of the article Xiaobian think good, now to share with you, think there is a need for friends can understand, hope to help everyone, the following with the idea of Xiaobian to read together.
The solution to php redis502 error: 1, use "sudo apt-get install php5-redis" or download phpredis on gitHub;2, recompile and install it.
Operating environment: Windows 7 system, PHP 5.5.30 version, DELL G3 computer
How to fix php redis502 error?
php redis set when nginx 502 solved
PHP Version 5.5.30-1+deb.sury.org~trusty+1redis 3.0.1,
php-redis extension installed by downloading pr.tar.gz, version 2.10.
Run $redis->set ('test ', 'hello world') and report nginx 502 error (nginx 502 error is a real headache).
The problem is located in $this->_redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP);
The reason is php-redis extension version 2.10, too low, you can use sudo apt-get install php5-redis or download it on gitHub
https://github.com/phpredis/phpredis
Install through compilation.
apt-get install Version 2.2.7.
public function conn() {undefined try {undefined $this->_redis->pconnect($this->host, $this->port, $this->timeout); // Set client option. must AFTER connected //var_dump(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP);exit(); $this->_redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP); //$this->_redis->setOption(0, 0); $this->_redis->auth("xxxrs"); //Here is the authentication password configured for redis $this->connected = true; } catch (RedisException $e) {undefined throw new CHttpException(500, "Redis occurs an error:" . $e->getMessage()); } }
If you use the red code, you will report a 502 error, while if you use the green code, you will have no problem.
setOption What is this? Check out php-redis api
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); //don't serialize data $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); // use built-in serialize/unserialize $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // use igBinary serialize/unserialize serialize $redis->setOption(Redis::OPT_PREFIX, 'myAppName:'); // use custom prefix on all keys redis key prefix $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); use this to report 502
Why do I go wrong with php's built-in serialization? What the hell happened?
Later, IGBINARY extension was installed, but it still failed. Finally installed php-redis latest version 2.24, and then run, there is no problem.
2.24 Version php-redis Source Code https://github.com/nicolasff/phpredis
======================
Redis::__construct constructor
$redis = new Redis();
connect, open link redis service
parameters
host: string, service address
port: int, port number
timeout: float, link duration (optional, default is 0, unlimited link duration)
Note: There is also a time in redis.conf, which defaults to 300
pconnect, popen links that do not actively close
above with reference
setOption Set redis mode
getOption View redis set mode
ping View connection status
The above is how to solve the php redis502 error problem all the content, more and how to solve the php redis502 error related content can search the previous article or browse the following article to learn Ha! I believe that Xiaobian will add more knowledge to everyone, I hope you can support it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.