# Hosting a Laravel Application with Easypanel

URL: /docs/quickstarts/laravel

Source: https://github.com/easypanel-io/monorepo/blob/main/apps/website/content/docs/quickstarts/laravel/index.mdx

Hosting a Laravel Application with Easypanel guide







































Laravel is a popular web application framework built with PHP, which provides an excellent structure for developing robust and scalable web applications. Easypanel is a web hosting control panel that simplifies web hosting management, automating several tasks, including server creation, application deployment, and configuration management.

In this guide, we aim to provide a detailed step-by-step approach to deploying a Laravel application on Easypanel. After following the steps below, you will have a Laravel application running and accessible via a publicly accessible URL.

## Prerequisites [#prerequisites]

Before we begin, ensure you have the following:

* A Laravel application running smoothly on your local machine ([sample codebase](https://github.com/easypanel-io/laravel-sample)).
* Easypanel running on your server.

## Step 1 - Creating a New Project on Easypanel [#step-1---creating-a-new-project-on-easypanel]

The first step is to create a new project from Easypanel. To achieve this, follow the steps below:

1. Log in to your Easypanel account.
2. Click on "New" to create a new project.
3. Specify the project's name.
4. Click on "Create" to complete the process.

<Screenshot>
    <img alt="New Project" src="__img0" />

    <img alt="New Project" src="__img1" />
</Screenshot>

## Step 2 - Setting up Your Application Service [#step-2---setting-up-your-application-service]

Once you have obtained your new project, the next step is to set up your application service. The application service represents your Laravel application, and you can set it up quickly by following the steps below:

1. Within the project dashboard, click on "+ Service"
2. Select "App" and specify the service's name and domain.

<Callout type="info">
  You can leave the domain blank and Easypanel will **generate** a subdomain for you.
</Callout>

<Screenshot>
    <img alt="New Project" src="__img2" />

    <img alt="New Project" src="__img3" />
</Screenshot>

## Step 3 - Configuring the Git/GitHub Source [#step-3---configuring-the-gitgithub-source]

If you plan to deploy your Laravel application from a repository, you must set up the Git repository source. Easypanel supports Git and GitHub to facilitate your automation process.

If you are using a private repository we suggest following the [Git SSH guide](/docs/code-sources/git-ssh)

<Screenshot>
    <img alt="Set git source" src="__img4" />

    <img alt="Set git source" src="__img5" />
</Screenshot>

## Step 4 - Choosing the Build Method [#step-4---choosing-the-build-method]

Easypanel allows you to deploy your Laravel application using two methods:

* Nixpacks: This is a package manager that simplifies building web applications for PHP developers. You can use Nixpacks to define the environment for your Laravel application and build it automatically.
* Dockerfile: Docker is a containerization technology that allows you to package your Laravel application with all its dependencies and deploy it as a container. You can use Dockerfile to define the environment for your Laravel application and build it automatically.

Follow the steps below to select your build method:

1. Navigate to the "Build" tab within your application service.
2. Choose either Nixpacks or Dockerfile and configure it according to your preferences and needs.
3. Save the changes, and a prompt will appear with the option to "Deploy."
4. Click on "Deploy" to initiate your deployment process.

<Screenshot>
    <img alt="Set git source" src="__img6" />

    <img alt="Set git source" src="__img7" />
</Screenshot>

## Step 5 - Configuring the Database [#step-5---configuring-the-database]

In order to configure your database you would have to first create a database service.

From the project's page you can click on "+ Service" and choose your database of choice, in this example we will use a MySQL database.

<Screenshot>
    <img alt="New Project" src="__img8" />

    <img alt="New Project" src="__img9" />
</Screenshot>

After you click on the MySQL card you will have to set a name and a password for your database. If you leave the password field empty Easypanel will generate a password for you.

<Screenshot>
    <img alt="Set git source" src="__img10" />

    <img alt="Set git source" src="__img11" />
</Screenshot>

As soon as you created the database you will be redirected to the service's page, where you will be able to get the information needed for the next step.

<Screenshot>
    <img alt="Set git source" src="__img12" />

    <img alt="Set git source" src="__img13" />
</Screenshot>

## Step 6 - Setting up Your Environment [#step-6---setting-up-your-environment]

Every Laravel application has an `.env` file that contains all the environment variables required for smooth operation. Use the "Environment" tab to set up your environment variables. Follow the steps below:

1. Navigate to the "Environment" tab within your application service.
2. Set your environment variables by specifying the key-value pairs as desired.
3. Add Nixpacks specific variables for Laravel
   ```
   NIXPACKS_PHP_ROOT_DIR=/app/public
   NIXPACKS_PHP_FALLBACK_PATH=/index.php
   ```
4. Save the changes to complete the process.
5. Press "Deploy" to apply the changes in your running app.

<Screenshot>
    <img alt="Set git source" src="__img14" />

    <img alt="Set git source" src="__img15" />
</Screenshot>

## Step 7 - Accessing and Testing Your Application [#step-7---accessing-and-testing-your-application]

Once your application is deployed, you can access it using the public URL generated by Easypanel.

<Screenshot>
    <img alt="Set Environment" src="__img16" />

    <img alt="Set Environment" src="__img17" />
</Screenshot>

## Conclusion [#conclusion]

Easypanel is an excellent hosting solution that simplifies the process of deploying web applications. By following the steps outlined in this guide, you can deploy your Laravel application in no time. Remember to keep your application up to date and secure to maintain smooth operations.
