Aug 18 2019

How to deploy your Laravel app to Digital Ocean using Laravel Forge

I've outlined every step including screenshots for setting up a Laravel website using Laravel Forge and Digital Ocean.

In this tutorial I will be setting up my new Laravel website ( on Digital Ocean using Laravel Forge.

Laravel Forge makes it trivial to get your Laravel app up and running on Digital Ocean (and other providers).

However, there are a bunch of steps!

I've outlined all of the steps required to go from having your Laravel app in a GitHub repo to having it hosted on a server with a MySQL database, SSL certificate installed and a Queue Worker running.

If you have questions about any of the steps or get stuck, be sure to check out the free Laracasts course on Laravel Forge.

Let's begin!

Select Digital Ocean

Select Digital Ocean from the list of supported servers on Laravel Forge.

Select Digital Ocean from the list of supported servers

Configure your server

I made the following changes to my server but feel free to configure your server to meet your needs. Once your done configuring your server, click [Create Server].

  • Region
  • Server Size
  • Database
  • Enable Digital Ocean Weekly Backups

Configure your server

Copy passwords

While your server is being provisioned, save the provided Sudo Password and Database Password to somewhere safe and secure like in 1Password or LastPass.

Save your passwords

Select your server

In the Active Servers section, you will see a list of your servers. Once your new server's status is set to Active, click the server name.

Select your new server

Select default site

Click on the "default" domain in the Active Sites section.

Click on the default site.

Select git repository

Select Git Repository to connect this site with an existing repository on Github.

Select a Git repository

Enter repository details

Add the name of your repository and configure any other settings you need. Then click the [Install Repository] button.

Enter repository details


After installing the repository, you'll need to wait a few moments.

Wait for repository installation


Click on the [Deploy Now] button in the Deployment box to deploy your code to Digital Ocean.

Deploy your site to your server

[optional] Enable quick deploy

Click the [Enable Quick Deploy] button to enable push-to-master deploys.

Enable quick deploy

Update nameservers

Log into your Domain Registrar (I'm using Hover in this example) and point your nameservers to Digital Ocean.


Update nameservers

Go to Digital Ocean's "Domains" section

Go to Digital Ocean > Networking > Domains

Go to Digital Ocean's Domains page

Add domain

Add your domain then click the [Add Domain] button.

Add domain to Digital Ocean

Add A record

Add a new A record with the following details and click the [Create Record] button.

  • WILL DIRECT TO your droplet's name

Add new A record

Add CNAME record

Add a CNAME record and click the [Create Record] button.

  • HOSTNAME www

Add CNAME record

Create a database

If your Laravel app requires a database, go back to the list of servers on Laravel Forge.

List of servers on Laravel Forge

Enter database details

Click the new server you created and then click the Database menu item in the left sidebar and enter your database details. Once done, click the [Add Database] button.

Enter database details.

Set up SSH keys

To connect your SSH key to Laravel Forge click the SSH Keys menu item in the left sidebar and add the name of your SSH key and the Public Key then click the [Add Key] button.

TIP You can quickly get your Public Key within Terminal by entering cat ~/.ssh/ | pbcopy command which copies your Public Key to your Mac's clipboard ready to be pasted into the Public Key textarea.

Set up your SSH keys

Test database connection

To test the connection to your database open Sequel Pro (which does NOT currently work with MySQL 8) or TablePlus (which does work with MySQL 8) and add a new SSH connection with the following details:

  • Name: Any name
  • MySQL Host:
  • DB User: (Name of User created when you created the database above)
  • DB Password: (Password created when you created the database above)
  • Database: (Name of Database)
  • SSH Host: IP address of site (listed on Digital Ocean)
  • SSH User: forge
  • SSH Key: ~/.ssh/id_rsa

Sequel Pro

Connect to database via Sequel Pro


Connect to database via TablePlus

Update .env values

Now you need to edit your .env values. To do this go to the Sites drop down menu in Laravel Forge and select your new Site.

Sites drop down menu

Click Environment

In the left sidebar, click the Environment menu item then click the [Edit Environment] button

Navigate to the Environment section

Edit Environment

Update the .env with necessary production values. Values you might update in the .env file are:


Update the required .env values

Associate with domain

Currently we haven't associated a domain. Let's fix that. For your Site, click the Meta link in the left sidebar. In the Domain section, replace default your website's domain name in the Site Domain field then click the [Update Domain] button.

Associate our site with our domain

Set up SSL

To configure your site to use SSL (which is recommended), click the SSL link in the left sidebar then select LetsEncrypt.

Select LetsEncrypt to add SSL certificate to your site

Obtain SSl certificate

You will see the Domains you are acquiring an SSL certificate for. Click the [Obtain Certificate] button to complete the process.

Obtain an SSL certificate for your site

[optional] Start Queue Worker

If you have queued jobs and need a queue worker to trigger those jobs click the Queue link in the left sidebar. Fill in the details (as per your requirements). For my site, I'm just going to use a database connection which is the only change I make to the Worker. Click the [Start Worker] button after you have configured all of the fields.

Set up queue worker

Now your site is live!

Congrats, enjoy and build something awesome.