Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that php can't connect to redis?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to solve the problem that php cannot be connected to redis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Php can not connect to the redis solution: 1, through the ". / src/redis-server configuration file-port port number &" command to open the redis server; 2, use iptables to open the port.

Operating environment of this article: linux5.9.8 system, PHP7.1 version, Dell G3 computer

What if php can't connect to redis? Some problems with the failure of php to connect to redis

1.redis extension

Class' Redis' not found appears when php reports an error, which is usually due to the fact that the redis extension is not enabled. Go to the https://pecl.php.net/package/redis address to download the redis extension corresponding to php. After linux compilation, windows downloads the dll file. The opening method is Baidu. This article mainly introduces the following two methods.

2.redis is protected (this only happens between two hosts)

The following error occurred when connecting to redis:

DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients.

The solution given by the author here is to go down

Bind 127.0.0.1

Change to

Bind 127.0.0.1 192.168.0.199 (Note: the intranet ip of the test server is 192.168.0.199)

Add the private network ip of the server to the back, which can be solved. Of course, if the communication between the internal networks adds the internal network ip, the external network adds the external network ip.

3.reids connect error

When a php link fails, there are two possibilities.

1. The redis server is not enabled, and the opening method is as follows:

. / src/redis-server configuration file-- port port number &

& is running in the background.

two。 The port is not open to the public (this only occurs between two hosts). The solution is as follows:

Please open the corresponding port number and open the port using iptables.

Since it is redis, for the sake of security, I recommend using the method of opening the port for the specified ip to avoid that anyone can connect to your redis server.

This is the end of the content of "how to solve the problem that php can not connect to redis". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report