Deploying Statamic with Laravel Forge

Laravel Forge provisions and deploys PHP applications on DigitalOcean,
Linode, Vultr, Amazon, Hetzner and other hosting platforms. It's our favorite way to deploy Statamic.

Assuming you have a Forge account, the first thing to do is authorize your hosting provider of choice. In this walk-through we'll use our preferred host, Digital Ocean as the example. This is a one-time step and will allow you to easily spin up and provision new server stacks anytime.

Deployment hosting setup example

You will need to also authorize Github (or your preferred source control provider). This is another one-time process that allows you to quickly deploy new sites from this account.

Deployment source control setup example

Spinning Up a New Server

Once you have connected to your hosting provider, the next step is to spin up a new server. Laravel Forge automatically tailors the server stack for Statamic and Laravel, so you only need to choose the server size most suitable for your project and you'll be billed accordingly by Digital Ocean.

Create server example

Creating a New Site

The next step is to create a new site. This will scaffold out the directory structure and nginx config on the server, and further allow you to configure your site's environment variables, deployments, and so on.

Create site example

Configuring Deployment

Finally, setup your deployment by pointing to your site to your source control repository. Laravel Forge will create a sensible deployment script for you for one-click deployments.

Install repo example

After doing this, you'll be able to customize the deployment script if needed. You can also enable "quick deploy", which will automatically trigger deployments when you push changes to your chosen branch.

Deployment script example

The Deploy Script area is where you'd add commands to install Composer and NPM dependencies, compile CSS and JavaScript if you need to, and clear Statamic's cache. Most deploy scripts look like something like this:

cd /home/forge/{example}.{tld}
git pull origin main
php please cache:clear
npm ci && npm run production

Advanced Control

Laravel Forge also offers advanced control of queue workers, cron jobs, SSL certificates, database access, etc.

Advanced Laravel Forge features
Forge does a lot. It's worth it.
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →