In this tutorial, we will show you how to configure a Redis instance on your account using the WebApps platform.
If you do not see a WebApps section in the Control Panel of your hosting account, this tutorial may not be suitable for your particular hosting environment. Please contact our support team for more information.
You need SSH access to the server in order to make the changes described in this tutorial. If you haven't set up SSH for your account yet, you should do this now.
Depending on your hosting plan, Redis may already be available. You can check if this is the case by running the following command over SSH:
redis-cli ping && echo "Redis is available!"
If there is no Redis instance available by default, you will receive an error message. In that case, you can set up a WebApps project to run your own Redis instance.
To do that, you should first create the configuration file for Redis by running the following commands:
mkdir -pv "$redis_dir"
cat <<REDIS_CONF > $redis_dir/redis.conf
# how redis will evict old objects - least recently used
After that, you can create and enable the WebApps project:
sureapp project create \
--engine "custom" \
--engine-version "-" \
--release-dir "$redis_dir" \
--start-cmd "/usr/bin/redis-server $redis_dir/redis.conf" \
sureapp service manage --enable "$sureapp_project"
sureapp service manage --start "$sureapp_project"
At this point, Redis should already be up and running.
You can check that by pinging it using the
redis-cli command-line tool:
redis-cli -s "$redis_dir/redis.sock" ping
You will receive a "PONG" reply if everything is working correctly.
In order to use your Redis server from your applications, you will just have to configure them to use the file system socket to connect. The path to the socket should be