I’m currently running Redis-server in my local development environment Ubuntu 20.04. Every time I open my desktop computer I always use this Redis-server --daemonize yes
to start the Redis server. Is there a way to make it autostart when the desktop computer turned on?
3
Answers
I fixed it using official redis documentation https://redis.io/topics/quickstart by Installing Redis more properly.
Here are the steps:
The following instructions can be used to perform a proper installation using the init script shipped with Redis 2.4 in a Debian or Ubuntu-based distribution.
Let's assume you already copied redis-server and redis-cli executables under /usr/local/bin.
1. Create a directory in which to store your Redis config files and your data:
2. Copy the init script that you'll find in the Redis distribution under the utils directory into /etc/init.d. We suggest calling it with the name of the port where you are running this instance of Redis. For example:
3. Edit the init script.
Make sure to modify REDISPORT accordingly to the port you are using. Both the pid file path and the configuration file name depend on the port number.
4. Copy the template configuration file you'll find in the root directory of the Redis distribution into /etc/redis/ using the port number as name, for instance:
5. Create a directory inside /var/redis that will work as data and working directory for this Redis instance:
6. Edit the configuration file, making sure to perform the following changes:
7. Finally add the new Redis init script to all the default runlevels using the following command:
8. You are done! Now you can try running your instance with:
Make sure that everything is working as expected:
Not sure about redis, I thought it already gets installed as a service. In general you can use systemd. Something like the following:
If your system is using
systemd
, the way to launch it at start-up is: