Deploying with Laravel Forge

This guide shows you how to really quickly deploy LaraOne CMS to cloud hosting provider DigitalOcean using a server provisioning and management tool Laravel Forge.

Note: This guide should not take more then 10-15 minutes to complete. 5 minutes if the reader is already familiar with Forge workflow and has servers already provisioned. In that case reader can jump over some steps.

Prerequisite

You will need an account at DigitalOcean and Laravel Forge to complete all the steps in this guide.

Connect Services

Once you create an account at Forge and login into it for the first time it will ask you to choose your default source control and server provider. For this guide we'll use GitHub and DigitalOcean.

To connect Forge and DigitalOcean you'll need to head over to your DigitalOcean account, enter API section and generate new API key that is used to connect Forge and DigitalOcean.

Once the key has been generated you need to copy and paste it into API Token input field on Forge seen in the first screen above and then press Connect. After successful connection has been established we can create our first DigitalOcean server using Forge.

Create a Server

First we need to create a server

We suggest using the simplest and cheapest 5$ droplet, with 1GB adn 1 CPU.

  • Name your server or leave the name Forge made up
  • Next Pick PHP 7.3 and MySQL 5.7
  • Database name can be forge as default

Once configured press Create Server, Forge will proceed to provision this server for you.

Note: Provisioning new server may take up to 10-15 minutes. Servers are provisioned only once, so this process does not need to be repeted per website you want to create. You can host as many websites on one server as you desire.

Create New Forge Site

We need to create a Site where we will install the CMS. Site is a Forge concept and you can think of it as representing your domain on Forge. To reach this screen, select the Server you just created and it will automatically bring you here.

Note: You only need to enter your domain, example of how that should look is provided on the screenshot above. Do not enter http or www, just mydomain.com will do. Once you press Add Site, it will take 1-3 minutes for Forge the create Forge site for you. Please wait till Forge is done before going to next step. Site should appear in the list of Active Sites.

DNS Settings

To be able to access your website using your domain name, you will need to point your domain to the server IP, server that Forge has created for you. This step is done at your domain registrar. Find your Server IP and head to your domainname registrar and update DNS information.

You will have to add two A Records and one CNAME record just like on screenshot below.

Note: Above screenshot is from Namecheap Domain Registrar. Your own provider may have different UI, but settings you need to add are the same.

Install Repository

Select newly created website. You will be offered two choices. Select Git Repository.

Once on Install repository screen enter GitHub as provider and for repository enter laraone/laraone. Once done press Install Repository.

You'll see below screen while Forge is cloing the repository for you.

Update ENV File

We need to customize default env file that comes with LaraOne CMS. To do that, we'll need to go to Environment section and press Edit Environment button.

To get going quickly, below settings in your env file should be updated to your needs.

You should set APP_NAME and APP_URL for your specific website.

    APP_NAME="My Website Title"
    APP_URL="http://mywebsite.com"

You should uncomment all ADMIN fields by removing the # sing in front of them. Then you should fill out all admin fields with custom values, do not leave these as they for security reasons.

    ADMIN_USERNAME=admin_username
    ADMIN_EMAIL=name@example.com
    ADMIN_PASSWORD=Example123456
    ADMIN_FIRSTNAME=firstname
    ADMIN_LASTNAME=lastname

Note: Admin values will be used when CMS is installed to create the first admin user. They can be removed later after successful installation.

Deploy Script

We need to customize default deployment script Forge creates for us. Default deployment script Forge creates looks like this.

php artisan migrate --force needs to be replaced with php artisan laraone:install.

Once done script should look like on the screenshot above. Make sure you save the update by pressing Save Script.

Deploy

Press Deploy Now

Note: If deployment is successful if you go to mywebsite.com/auth/login you should be able to login with admin you specified in previous step. At this point you can start building your website.

Update Deploy Script

You need to update deploy script again.

Inside Forge deploy script php artisan laraone:install needs to be replaced with php artisan laraone:update. If this is not done, next time you try to deploy this Forge Site, it will run laraone:install command and overwrite previous installation.