This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Join our live AMA on the Future of Page Builders with Brizy's CEO! Register Now →

How to Setup Laravel Application on Cloudways With Redis Cache

Updated on July 8, 2021

3 Min Read

Laravel provides a number of cache drivers like a database, Memcached, and Redis. Out of these options, Redis Cache for Laravel 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 up Redis Cache in Laravel 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:
    redis-cli ping

    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
    composer require predis/predis

  5. The Redis configuration for your application is located in the config/database.php file
    'redis' => [
    
       'client' => 'predis',
    
       'default' => [
           'host' => env('REDIS_HOST', 'localhost'),
           'password' => env('REDIS_PASSWORD', null),
           'port' => env('REDIS_PORT', 6379),
           'database' => 0,
       ],
    
    ],
    

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

Get Ready for Core Web Vitals Update

Ebook to Speed Up Your Website Before You Start Losing Traffic.

Thank You

Your list is on it’s Way to Your Inbox.

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.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Ayaz Ahmed Khan

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

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now