How to Deploy Laravel Reverb in Production with Cyberpanel?

QASource Engineering Team | November 25, 2024

How to deploy Laravel Reverb in production with Cyberpanel

Deploying a Laravel project like Laravel Reverb in a production environment using CyberPanel provides a seamless setup experience. Using CyberPanel’s features, you can easily manage server configurations, website creation, and secure database connections, optimizing Laravel’s capabilities for a production setting. This guide will walk you through the necessary steps, from server preparation to testing your application, ensuring your Laravel app runs smoothly and securely.

To project, such as Laravel Reverb, in a production environment using CyberPanel, follow these steps:

Step 1: Prepare Your Server

  • Install CyberPanel:
    • If it is not already installed, set up CyberPanel on your server by following the instructions in the official CyberPanel installation guide.
  • Update Your Server using the below command:
    • Ensure your server has the required dependencies:
      • PHP (which is compatible with the installed Laravel version)
      • Composer
      • MySQL or MariaDB

Step 2: Set Up the Website

  • Create a New Website in CyberPanel:
    • Log in to the CyberPanel dashboard.
    • Go to Websites > Create Website.
    • Fill in the required fields (Domain Name, PHP Version, etc.).
    • Click Create Website.
  • Add a Database:
    • Go to Databases > Create Database.
    • Fill in the details and create the database.

Step 3: Upload the Laravel Project

  • Compress Your Laravel Project:
    • Zip your Laravel project folder on your local machine.
  • Upload the Project to CyberPanel:
    • Go to File Manager > [Your Website's Root Directory].
    • Upload the zipped Laravel project.
    • Extract the archive in the public_html folder or the root directory (depending on your preference).
  • Now, the next step is to set the Web Root as a public Directory :
    • Navigate to Websites > List Websites in CyberPanel.
    • Click Manage for your website.
    • Under Document Root, set it to public.

Step 4: Configure Laravel

  • Install Dependencies:
    • SSH into your server: ssh user@your-server-ip
    • Navigate to the project directory using the following command: cd /path-to-your-project
    • Install Laravel dependencies: composer install
  • Set Up the Environment File:
    • Copy the .env file using the command as: cp .env.sample .env
    • Edit the .env file to configure database credentials and other settings: nano .env
  • Then, generate the Application Key with the command "php artisan key:generate" followed by "php artisan migrate—-seed" to run Migrations and Seeders.

Step 5: Set Permissions

  • Ensure proper file permissions:
  • sudo chown -R www-data:www-data /path-to-your-project
  • sudo chmod -R 775 /path-to-your-project/storage /path-to-your-project/bootstrap/cache

Step 6: Configure CyberPanel and Laravel for Production

  • Set Up Virtual Hosts:
    • Configure the NGINX/Apache virtual host in CyberPanel to point to the Laravel public directory if required.
  • Enable SSL:
    • Go to Websites > Manage SSL.
    • Get an SSL certificate issued for your domain.
  • Optimize Laravel for Production:
    • php artisan config:cache
    • php artisan route:cache
    • php artisan view:cache
  • Restart Web Server:
    • sudo systemctl restart nginx
    • sudo systemctl restart php7.x-fpm

    Step 7: Test the Application

    • Access your Laravel application using the domain or IP you configured.
    • Verify the application works as expected.

    With these steps completed, your Laravel Reverb application should be fully deployed and optimized for production on CyberPanel. Ensuring the proper configuration, permissions, optimization commands, and SSL and caching setup will allow for a stable, secure, and efficient application.

Disclaimer

This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment

Categories