How to deploy Statamic to your own VPS.

Statamic is a Laravel application, so it needs what Laravel needs on a VPS: Nginx, PHP-FPM, Composer, Node.js for the asset build and a way to deploy from Git. ServerDog sets that up from your Mac and deploys each commit as a new release. Because Statamic keeps content in files, the one thing to plan is how content edited on the server gets back into your repository.

By ServerDog. Updated .

Key facts

  • ServerDog’s Statamic preset uses the same defaults as its Laravel preset: Composer, an asset build and artisan migrate, in a new release folder.
  • The storage folder and the .env file are shared between releases. Everything else comes fresh from Git on each deploy.
  • Content edited in Statamic’s control panel on the server is written to the live release, and is not carried into the next one unless it reaches Git.
  • ServerDog creates .env with a generated APP_KEY, APP_ENV=production and the database settings.
  • Deploy on Push deploys your branch within a minute of each commit, with no webhook.

Before you start

  • A Mac running macOS 15 or later, with ServerDog installed.
  • A Hetzner, DigitalOcean or Vultr account, or a fresh Ubuntu 24.04 or 26.04 server from any provider.
  • Your Statamic site in a GitHub, GitLab or Bitbucket repository.
  • A domain whose DNS you can change.

1. Set up the server

Choose Add Server and pick App server and the PHP version your site needs. ServerDog installs Nginx, PHP and Composer, a database, Redis and Node.js, and sets up the firewall. Setup usually takes 8 to 12 minutes and runs on the server, so you can close the window.

2. Create the site

Choose New Site and the Statamic preset. Type the domain, pick the PHP version, and add the repository URL and branch. ServerDog writes an Nginx config that serves the public folder and gives the site its own read-only deploy key.

3. Set the environment

ServerDog writes the site’s .env with a freshly generated APP_KEY, APP_ENV=production, APP_DEBUG=false, your domain as APP_URL and the settings of the database it created. Open the site’s Environment tab to add the rest, such as your Statamic licence key and mail settings.

4. Deploy

Press Deploy. The Statamic preset starts from the same script as the Laravel one:

$CREATE_RELEASE()

cd $SERVERDOG_RELEASE_DIRECTORY

$SERVERDOG_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
npm ci
npm run build
$SERVERDOG_PHP artisan migrate --force

$ACTIVATE_RELEASE()

$RESTART_QUEUES()

The script is yours to change. Statamic keeps its content index, the Stache, in storage, which is shared between releases, so most sites add a line before $ACTIVATE_RELEASE() to rebuild it from the new files:

$SERVERDOG_PHP please stache:refresh

If something fails before the switch, the site keeps serving the previous release. Read how zero-downtime deploys work.

5. Point the domain and turn on HTTPS

Create a DNS record for your domain that points at the server’s IP address. ServerDog waits for DNS, requests a free Let’s Encrypt certificate and shows how long it is valid. The server renews it from then on.

6. Decide where content is edited

By default Statamic stores entries, users and assets as files in your project. On the server those files sit inside the live release folder. Each deploy checks out a fresh release from Git, and only storage and .env are carried over. So an entry saved in the control panel on the server exists only in that release, and the next deploy goes live without it.

Two setups avoid that:

  • Edit locally, deploy by pushing. Run the control panel on your own computer, commit the content and push. With Deploy on Push the change is live within a minute.
  • Keep content in the database. Statamic’s Eloquent driver stores entries and other content in the database ServerDog created, which deploys do not touch.

ServerDog’s deploy key is read-only, so the server cannot push commits back to your repository with it.

7. Turn on Deploy on Push

In the site’s deploy settings, turn on Deploy on Push. The server checks the repository itself and deploys your branch within a minute of each new commit. There is no webhook to set up, and your Mac doesn’t need to be on.

Does the scheduler or a queue need anything?

Statamic sites have the same switches as Laravel sites in Settings, under Processes: Scheduler runs php artisan schedule:run every minute, Horizon manages queue workers, and you can add a queue worker as a process. Read how ServerDog runs workers.

What you end up with

A plain Ubuntu server running Nginx and PHP-FPM, with your Statamic site deployed in release folders and served over HTTPS. Nothing on it is tied to a hosted service: remove the server from ServerDog and it keeps running exactly as it is.

Go deeper

Questions

What do I need to host Statamic on a VPS?

The same as a Laravel app, because Statamic is one: Nginx, PHP-FPM with Composer, Node.js to build assets, and a way to deploy from Git. A database is optional, since Statamic keeps content in files by default.

Does Statamic need a database on the server?

Not by default. Statamic stores content, users and settings as files in your repository. ServerDog creates a database for the site anyway and writes its settings to .env, so it is there if you use the Eloquent driver, queues or sessions in a database.

What happens to content I edit in the control panel on the server?

It is written to files inside the live release. The next deploy checks out a fresh release from Git, so edits that never reached your repository are not in it. Edit content locally and push, or keep content in the database with Statamic’s Eloquent driver.

Are Statamic deploys zero-downtime?

Yes, by default. Composer, the asset build and migrations run in a new release folder, and the site switches to it in one step when they finish. If the script fails first, the site keeps serving the previous release.

Do I need to clear Statamic’s cache when I deploy?

Usually, yes. Statamic keeps its content index, the Stache, in the storage folder, which ServerDog shares between releases. Add php please stache:refresh to the deploy script so each release rebuilds it from the new files.

Can ServerDog run the Statamic scheduler and queues?

Yes. Statamic sites have the same switches as Laravel sites: Scheduler runs artisan schedule:run every minute, Horizon manages queue workers, and you can add a queue worker or any other command as a process.

Last updated by ServerDog.

Your servers. Your Mac. Nothing in between.

For macOS 15 or later.