Deploying Laravel on CloudStation
Introduction
Laravel is a widely used PHP framework that provides a structured and scalable approach to web application development. With its expressive syntax and extensive feature set, Laravel simplifies the process of building robust applications.
This guide explains how to deploy a Laravel application on CloudStation, ensuring a seamless and efficient deployment process.
Prerequisites
Before proceeding with the deployment, ensure you have the following requirements met:
- A Laravel Application: You can either create a new Laravel project or use an existing one.
- GitHub Account Connected to CloudStation: CloudStation supports GitHub integration for automated deployments. You can learn how to link your GitHub account here.
Preparing Your Laravel Application
Before deploying, ensure your Laravel application is correctly set up by following these steps:
-
Install Dependencies
Run the following command in your Laravel project directory to install all required dependencies:composer install
-
Configure the Environment File
-
Duplicate the example
.env
file:cp .env.example .env
-
Edit the
.env
file to match your application and database configurations.
-
-
Generate the Application Key
php artisan key:generate
-
Test Your Application Locally
Start the Laravel development server:php artisan serve
Visit http://localhost:8000 to confirm your application is running properly.
Deploy Laravel on CloudStation
Deploying Laravel to CloudStation
-
Log in and Create a New Project or Select Existing one
-
Log into CloudStation, go to Dashboard > New Project, and Add New Git Repo. Select your Laravel project and import it.
-
If you don't have a project, create a new one.
-
-
Initiate a New Deployment
- Click the Add New button.
- Choose Git Repository as your deployment source.
More details
-
Connect Your GitHub Repository
- If your GitHub account isn't linked, follow the prompts to connect it.
- Select your Laravel project repository from the available list.
More details
-
Set Up Deployment Configuration
- Choose the appropriate PHP version for your application.
- Add necessary environment variables (e.g.,
APP_KEY
,DB_CONNECTION
,DB_HOST
) from your.env
file. - Ensure the web root directory is set to
public/
.
More details
-
Deploy Your Laravel Application
Click Deploy to initiate the deployment. CloudStation will fetch the latest code from your repository and deploy your Laravel application automatically.
Edit this file on GitHub