How to Deploy Laravel Project on Cloudways Server

This simple KB will help you deploy Laravel applications on Cloudways managed servers with just a few clicks.

Emmad avatar
Written by Emmad
Updated over a week ago

Table of Contents

Laravel is a popular PHP development framework used to build everything from simple eCommerce store backends to enterprise portals. It is an Open Source MVC architecture that allows for rapid application development and continuous integration of the applications.

Developers could take advantage of the modular packaging system (bundles in Laravel) that takes care of application dependencies through a dependency manager known as Composer. Deploying the Laravel application is an important aspect of the project cycle that has a far-reaching impact on the functionality and health of the project.

This simple KB will help you deploy Laravel applications on Cloudways managed servers. Note that you can deploy your Laravel application on new or existing servers. For the purpose of this Knowledge Base article, we will use an existing Cloudways server.

How to Deploy Laravel Project on Cloudways Server

Step 1: Install Laravel Application

After logging into the Cloudways Platform, click on Servers in the top menu bar and select the target server on which you want to deploy the Laravel application.

Classic Interface

New Interface

Now at the bottom right, click on the circular grid icon, and select Add App for creating a new application.

Classic Interface

New Interface

Select the Laravel application and click on the Add Application button. This will take a few minutes for the setup to complete.

Step 2: Deploy the Application from a Repository

Select the application installed in Step 1, and go to the Application Manager. Click Deployment via Git.

Add the Remote Repo URL in the Git Remote Address field and click on the Authenticate button. This will clone your application on the Cloudways server.

Classic Interface

New Interface

Step 3: SSH to Your Server

Go to the Server Manager and click the Launch SSH Terminal button. This will open the terminal to the server.

Classic Interface

New Interface

Provide the Master Credentials (username and password) available on the Server Management page.

Step 4: Run the Composer

In the terminal, go to the application and then to the public_html folder.

cd application/[applicationName]public_html

Execute the Composer Update command for updating the dependencies of the Laravel application. Note that your application folder name is mentioned on the Access Detail Page.

composer update

Step 5: Update the Environment Configurations

Open the .env file and update the necessary configuration changes such as application name and database information.

Step 6: Execute Database Migration and Seeder [OPTIONAL]

If you already have a database for your Laravel application and you are deploying it for the first time on a Cloudways managed server, you will need to migrate and seed the database.

For this, use the following commands:

php artisan migrate:fresh
php artisan db:seed

Once the process finishes, you can double-check the steps by clicking the Launch Database Manager button.

Step 7: Set up Laravel Scheduler

When you need a scheduler for the Laravel application, you only need to add a cron entry to your server. For this, you need to go to Cron Job Management and click on Advanced. Now add the following script, and click Save.

*  *  *  *  *  /home/[serverFQDN]/[AppUsername]/public_html artisan schedule:run #CloudwaysApps

Classic Interface

New Interface

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?