Use Laravel Forge to Automate Web-Server Creation on a Linode
Updated by Onwuka Gideon Written by Onwuka Gideon
What is Laravel Forge
Laravel Forge is a tool for deploying and configuring web applications. It was developed by the makers of the Laravel framework, but can be used to automate the deployment of any web application that uses a PHP server.
Creating a fully-functioning web server is normally a complicated and time-consuming process, involving the installation of multiple components such as Nginx, MySQL, and PHP. Laravel Forge automates all of the necessary installation and configuration, allowing you to get your website up and running quickly.
Once your server has been created, deploying updates becomes as simple and painless as pushing to your repository on Github. Also, you can easily manage the configuration of your website though a web interface. Finally, Forge automatically provides advanced security features, such as free SSL certificates (through Let’s Encrypt) and automatic firewall configuration.
Before You Begin
Sign up for a Laravel Forge account if you do not have one.
Link to a Source Control Service
If you want to be able to quickly deploy from Github, Gitlab or Bitbucket, you will need to link these sites to your Forge account. From your Forge dashboard, select the Your Profile tab.
Choose your preferred source control by clicking on the Source Control link on the Left.
Click on the source control service you would like to connect to.
Once you link to a source control service, you will be prompted to authorize Laravel Forge. You will then be redirected back to Forge’s website.
Adding Your Linode API Key to Forge
Open your Laravel Forge Dashboard.
Click on Service Providers.
Select Linode and input your API key.
Create a Server
Click on Linode.
You will then be provided with some options:
Credentials: Any cloud providers that you have linked to your account.
Name: A name for your server. You can choose any name you like.
Server Size: The size of the server.
Region: The data center where you want your server hosted. Choose a location close to where you expect the majority of users to be.
PHP Version: The installed PHP version.
Database Name: If your application needs a database, then you can name it here. By default it will be named
Once you have finished selecting options, click Create Server. A pop up will show you the sudo and database passwords that have been automatically generated for you. Be sure to copy these values and store them in a secure place.
Forge will now perform the steps necessary to create and configure a Linode based on the settings you chose earlier.
A green check in the Status column means the server is active. This will take a few seconds.
Navigate to the public IP address of your Linode in a browser.
When the setup process has completed, you will receive an email containing details about your new server.
Add a Domain Name
If you want to use Let’s Encrypt to obtain a free SSL certificate for your website, you will need to buy a Fully Qualified Domain Name (FQDN) and set it to point to your new server.
Head back to Laravel Forge account then click on the active server.
Go to your domain name provider, add an ANAME record for the domain or subdomain, and point it to the public IP address of your server.
- Root Domain: This is your domain name.
- Project Type: This is the type of project you are using. If you are building regular PHP, you can choose
General PHP/Laravel. Other options include Static, HTML, Symfony, and Symfony (Dev).
- Web Directory: This is the directory from which public files will be served.
Submit the form by clicking ADD SITE.
NoteIf you do not add a domain name, you can still access your server through its public IP address.
Add a Repository
Click on your active servers. Under the active site, choose the domain name you added in the previous step.
Click Apps on the left-hand side and then select your Git repository.
Fill in the repository field with your username and repository. Then select the branch you want to use. Click on INSTALL REPOSITORY. Observe that the repository field is
gitlab_username/repository_name_without_.git. The sample image below shows
If you visit the website again, the repository is now copied to your Linode server and everything is set up.
These steps will show how to immediately deploy changes from the source directory to the live site.
From the INSTALL REPOSITORY menu, toggle Quick Deploy to “on”.
Make changes to your project on Github or Gitlab and commit them to the master branch. Your live site will be updated to reflect the changes.
Adding SSL to Your Domain Name
SSL (Secure Sockets Layer) is the standard security technology for establishing an encrypted link between a web server and a browser. To add SSL:
Choose your server on Forge.
Select the domain name of your server.
Click on SSL from the menu on the left.
Laravel Forge comes with Let’s Encrypt which help us generate a free SSL certificate.
If you already have an SSL certificate, click on the Install Existing Certificate. Otherwise, select LetsEncrypt (Beta).
If you chose to use LetsEncrypt, you will be presented with a button to obtain a certificate. Click on it and allow it to install.
Activate your new certificate by clicking on the activate icon.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
Join our Community
This guide is published under a CC BY-ND 4.0 license.