How to Setup Laravel Application on Cloudways With Redis Cache

by Ayaz Ahmed Khan  October 19, 2017

Laravel provides a number of cache drivers like a database, Memcached, and Redis. Out of these options, Redis Cache is the best because it is different from Memcached in the sense that it has persistence. Further advantages of Redis over Memcached are that it works with more data types, and it uses less memory.

laravel redis

Cloudways offers Laravel on its Managed Cloud Web Hosting Platform. I’m writing this blog post to help you set it up in a jiffy!

Let’s begin.

Setting up Laravel Application on Cloudways

Signup at Cloudways; Select Laravel 5.5 as your application; Fill in your application and server name and launch the server. Your new Laravel 5.5 application will be launched within minutes, as shown in the GIF below.

Enable Redis on Cloudways Server.

I assume that you are signed into your Cloudways account. Follow these steps:

  1. Select Server Management tab
  2. Go to Server Settings & Packages tab
  3. Press the Packages button and turn on Redis by clicking the Install button

In a few moments, Redis is installed and enabled on your Cloudways server.

Setting up Redis on Laravel

Now that the Redis is installed and enabled on your server, let’s set it up on your Laravel 5.5 application. For this, follow these steps

  1. Go to the Application Management tab.
  2. Get your application’s SSH terminal and start a SSH session using the provided SSH credentials.
  3. Now to make sure that Redis is working, type the following command:

    If you get PONG in response, Redis is enabled on your server.

  4. Before using Redis with Laravel, you will need to install the predis/predis package (~1.0) via Composer. To do that, type the following command in terminal

  5. The Redis configuration for your application is located in the config/database.php file

    In the config/cache.php file, you can change your default cache driver from file to Redis, and start using Redis in your application.

Conclusion

You’re done! I hope this post was helpful for those who want to activate Laravel app along with Redis cache on Cloudways Cloud Console. If you have any question, feel free to ask in the comments section below. To check out the features offered by Cloudways for Laravel users, visit this page.

Create Laravel apps without the worry of server management.

Deploy your app on optimized PHP hosting servers for Laravel.

About Ayaz Ahmed Khan

Ayaz Ahmed Khan works as Senior Research and Development Engineer at Cloudways.

Stay Connected:

You Might Also Like...