-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Redis instructions #68
base: main
Are you sure you want to change the base?
Conversation
I added a note about using different Redis instances for different applications since upstream documents this very poorly and it took me literal years of operating Redis to figure this out for myself. |
- Set `REDIS_PORT` to `null` | ||
|
||
If you are using a Unix socket | ||
- Set `REDIS_SCHEME` to `unix` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REDIS_SCHEME and REDIS_PATH are only for using Predis instead of phpredis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm. I set REDIS_HOST
to the Unix socket, like the docs said, and I got a stack trace about that being unexpected. Can't recall what exactly it said. I had to follow the proposed instructions here to get it to work. Bug?
|
||
::: tip TCP server vs. Unix socket | ||
Redis usually comes pre-configured to listen for TCP requests on the local machine over port 6379. In your Redis configuration, typically at `/etc/redis.conf`, the relevant lines are `bind 127.0.0.1` and `port 6379`. | ||
|
||
Changing the latter line to `port 0` will disable TCP listening, in which case Redis must be configured for socket access. Lines such as `unixsocket /run/redis/redis.sock` and `unixsocketperm 770` must be set to enable socket access. Additionally, both the app user and web user should have permission to access the socket, e.g. by being added to the `redis` group. | ||
|
||
Using a Unix socket is optional, but may provide faster access since it does not have to create TCP packets. TCP is usually used over a network, and would be required if Redis were running on a different machine than your web server. | ||
Using a Unix socket is optional, but may provide faster access since it does not have to create TCP packets. TCP is usually used over a network, and would be required if Redis were running on a different machine than your web server. Unix sockets are also helpful for running more than one Redis instance on the same machine, which you might want to do if you have more than one application using Redis (a single Redis instance [should not be used](https://redis.io/commands/select) by multiple unrelated applications). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't one also theoretically run multiple instances of Redis on the same machine via multiple TCP ports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, but if you're not going to use the default Redis listening configuration anyway, you might as well make it listen on a Unix socket. (That is why I just said "it's helpful" though instead of saying that was the way to do it. I can rephrase if you want.)
No description provided.