Skip to main content

Laravel Deployment

On KloudBean, you get a complete production-ready stack to host high-performance PHP Laravel applications with ease in just a few steps.

You get:

  • Git Integration: Pull your code on the server
  • SSH Access: Access to the server to run Composer and Artisan commands
  • File Manager Access: Add, update, and manage files with ease

Launch New Laravel Application

note

If you already have a server and wish to launch an app on it, go to ApplicationsAdd Application and add a Laravel app on the existing server.

In this example, we will create a brand new server.

In order to launch your first Laravel app on a new server, navigate to the server provision page:

  1. Select Cloud Provider
  2. Select "Laravel" from application dropdown
  3. Add Application Name
  4. Add Server Name
  5. Select Server size (for Laravel, minimum recommended size is 4GB)

Laravel Launch Step 1

  1. Click on "Launch" button and proceed with the payment process (trial or payment)

Once payment is completed, server with Laravel app provisioning will be initiated.

Wait for a while; it will take 5-7 minutes to create your server, configure, and deploy a high-performance PHP web stack.

By default, on a new server you will get the following stack versions:

  • PHP-FPM: 8.2+
  • MariaDB: 10.6+
  • Node: 20.X
  • Composer: Latest
  • Redis: Latest

Access Application Administration

Once your server is ready, in order to access the Laravel app, select "Apps" from the header menu to go to the Applications page.

On this page, you will see your application in active status.

Laravel Launch Step 2

Click on it to navigate to "Application Administration""Access" section.

On this section, you will see:

  1. Application default access URL
  2. Server public address to point your custom domain to it

Laravel Launch Step 3

Deploy Your Code

The next step is to deploy your code.

In order to deploy your code, navigate to the "Code Delivery" tab.

Here, stay on the first tab, which is "Git Deployment".

Click on "Enable Git Integration" and add your repo URL to connect your repository and clone it.

In this example, I'm going to deploy the open-source Laravel app "BookStack":

https://github.com/BookStackApp/BookStack.git

Laravel Deploy Step 1

In order to connect a private repo, read the detailed guide on Connecting Git Repository.

Once the repo is cloned, the next step is to access your code files using the file manager.

Navigate to the third tab "FileManager" and click the "Launch FileManager" button to open it in a new tab.

Laravel Deploy Step 2

Once you are in the file manager, here you will see all your files.

Updating .env File

To add variables like site URL and database variables:

  1. Locate the .env file, or rename .env.example, or you can create a new file and name it .env and add environment variables in it.

Laravel Deploy Step 3

  1. Double-click on the .env file to edit it. Once the editor opens, update the required variables.

In this example, I updated:

APP_URL=https://laravel-232200300.kloudbeansite.com

# Database details
DB_HOST=localhost
DB_DATABASE=kb_u27hulkz3c
DB_USERNAME=kb_u27hulkz3c
DB_PASSWORD=PydV7ZOqwb612ce469

In order to get database access credetials, read the detailed guide on Viewing Database Credentials.

Laravel Deploy Step 4

  1. Once updated, click on the "Save" icon on the top right corner of the editor, and it will be saved.

Execute Composer and Artisan Commands

The next step is to execute the required Composer and Artisan commands to initialize the application and perform migrations.

In order to execute these commands, you have to SSH into the server to run commands.

To SSH into the server, read our detailed guide: Getting Server Access Credentials.

Once you are connected to the server, execute the cd command to navigate to your application root directory:

cd /home/admin/hosted-sites/<app_system_user>/app-html/

Once you are inside that directory, you can view your files using the command:

ls -l

Laravel Command 1

In this directory, execute the command:

composer install --no-dev

Laravel Command 2

The next step is to execute the command artisan key generate to generate a unique application key.

php artisan key:generate

Laravel Command 3

Now Execute artisan migrate commands to update the database.

php artisan migrate

Laravel Command 4

Done! You can now login using the default admin details [email protected] with a password of password. You should change these details immediately after logging in for the first time.

Congratulations! Your code is deployed and ready to access in a production-ready, high-performance, and secure environment.

Your application is now ready and good to access. Go to "Application Administration""Access""Access URL", and access your app.

If you see old content, follow the following steps to clear your cache:

Purge Cache

Purge Varnish Cache

To purge Varnish cache, go to "Server Administration""Service Management"Varnish → click "Purge".

Purge Varnish

Clear App Cache

Execute the following Artisan cache commands:

php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

Next Steps