Deploy a PHP Laravel Application using Kloudbean.

Why Choose Kloudbean for Your Laravel Application?

  • Deploy your Laravel application with ease, getting your app online in just a few clicks.
  • Kloudbean ensures multi-layered security for your Laravel application, including application isolation, encryption, and firewall configurations.
  • Easily set up custom domains for your Laravel application, with Kloudbean providing free SSL certificates to ensure secure connections for your users.
  • Kloudbean optimizes servers, ensuring your application runs with maximum efficiency. With Nginx as the web server, optimized PHP-FPM configurations, and Apache support, your app is fully optimized to handle production traffic.
  • Take full advantage of Nginx FastCGI caching to serve cached content with blazing speed, reducing the load on your PHP backend and improving response times for end users.
  • Leverage highly optimized PHP-FPM configurations that provide fast and efficient processing of PHP requests, ensuring minimal resource usage and lightning-fast performance under heavy traffic.
  • Kloudbean supports both Nginx and Apache, giving you the flexibility to choose the right web server for your Laravel app, and ensuring seamless performance with robust caching and load balancing support.
  • Kloudbean offers one-click deployment for your Laravel application, ensuring you spend less time managing infrastructure and more time building features.

Deploying and Running Your PHP Laravel Application

Now that you understand the advantages of hosting your Laravel application on Kloudbean, let’s dive into how you can deploy and run your PHP Laravel application on the platform. Kloudbean’s user-friendly interface makes it easy to get started, ensuring that your application is production-ready with minimal setup. Follow these simple steps to deploy your Laravel application on Kloudbean.

Step 1: Creating new Laravel application on new server

This step involves;

  • Choosing Cloud Provider
  • Choosing Application
  • Choosing Datacenter with nearest location
  • Adding Application Name
  • Adding Server Name
  • Selecting Server size depending on needs.
Create New Laravel Application on new server.
Create New Laravel Application on new server.

Once application installation process is completed. Go to Apps tab and Click on the application that just has been created. It will take you to the Application Administration section.

Go the Application section from the top menu.
Go the Application section from the top menu.

From the Application Administration section you are going to see following important fields that will be require in further app deployment process.

  1. Application access URL: This is the default access url provided by kloudbean.
  2. Database Name: This is the database that has been automatically created for this app.
  3. Database Username: This is the database user, created automatically.
  4. Database Password: This is the password for the above user to access database.
  5. Launch Database Manager: This button will take you to phpmyadmin where you can access your database using these same credentials and perform any query.
Application Administration and Database Credentials.
Application Administration and Database Credentials.

Step 2: Deploying Application with Git.

In order to deploy your code through Git, Follow these steps:

  1. Go to Deploy Code section, Click on GENERATE SSH KEY, if not already generated. If your repo is private, then you can get SSH key by clicking on SHOW SSH KEY.
  2. Once SSH keys are added in your private repo (not required for public repo), Copy Git Address from your Github and paste it to Git Branch Address field.
  3. Select your branch that you wants to deploy from Branch field.
  4. Once above steps are done, Click on Clone Now Button to clone your repo.

Additionally you can see your code using kloudbean File Manager feature, by clicking on LAUNCH FILE MANAGER button.

Adding Git repository to connect it with kloudbean.
Adding Git repository to connect it with kloudbean.

For demo purpose we are going to deploy open-source application BookStack from Github repository. 

If you to learn more how to clone Git repo, Read this

An example of copying Git repository address from Github.
An example of copying Git repository address from Github.

Step 3: Updating .env file

Once Git repo is cloned successfully. Next step is to update env file with the database credentials and other required configurations. In order to do that, we need to follow these steps;

  1. Access File Manager by clicking on LAUNCH FILE MANAGER button from Code Deploy section.
  2. Scroll down to file names .env.example and remain it to .env by clicking on pen icon from top menu.
  3. Double click on .env file, this will open the file in Edit mode to update it.
Adding .env file for app configurations.
Adding .env file for app configurations.

Step 4: Adding Database Credentials 

Once .env file is created and ready to update. Update following fields in the file.

  1. DB_HOST: we don't need to update it, as database is running on same server so localhost value is fine.
  2. DB_DATABASE: Copy database name from Application Administration section as mentioned above and paste it here.
  3. DB_USERNAME: Copy database username as well and paste it here.
  4. DB_PASSWORD: Update password as well.

Additional APP_URL is going to be the URL of application, in this case we will update this field as well and replace it with the kloudbean's provided default url.

Updating Database and other configurations.
Updating Database and other configurations.

Step 5: SSH into server to execute php commands

In order to ssh into server. You can get Server IP Address, Username and password from Server Access section.

  1. Go to Server Access section.
  2. Copy access credentials and add this into your terminal ssh <admin-user>@<ip-address>.
  3. Followed by password. and hit Enter.
  4. Go to application app-html directory where code has been cloned already by using command cd /home/admin/hosted-sites/<app-system-user>/app-html
SSH into Application Server.
SSH into Application Server.

If you to learn more about how to ssh server Read this

Step 6: Executing php commands

Once you are in the app-html directory, run following compose command in order to install your project's required dependencies.

composer install --no-dev

As a result of this command all dependencies should be installed.

Installing dependencies using compose command.
Installing dependencies using compose command.

Once dependencies are installed, Next step is to generate key using following php command;

php artisan key:generate

After this execute one last command to create required tables on database.

php artisan migrate

As a result of above commands, your application should be fully ready to access it.

Executing php artisan commands.
Executing php artisan commands.

Optionally Accessing Database

Kloudbean provide phpmyadmin with each server, in order to access application database. By just clicking on LAUNCH DATABASE MANAGER from Application Administration section and followed by adding database credentials, you can access database and perform any query by selecting the require database.

Accessing Application database (Optional).
Accessing Application database (Optional).

Accessing the Application

By now your application is fully deployed and ready to serve traffic. You can access your application by clicking on Launch icon of your application in kloudbean Apps section, or from Application Administration section.

BookStack Application is successfully accessible.

Accessing the application from default url.
Accessing the application from default url.

With Kloudbean’s powerful features, deploying your PHP Laravel application has never been easier. The platform manages your server configuration, scaling, security, and performance optimization, so you can focus on building and growing your application.

Read how to enable auto deployment using CI/CD.

Was this article helpful?

Build and Host Angular Application using Kloudbean.