Forge, NGINX and Kirby CMS

I'm a big fan of Laravel Forge for provisioning servers.

Generally setting up a Kirby site is very straight forward, especially on Apache, but with default Forge setup (and Nginx) there are two small things that has tripped me up a few times already. That's why I make these notes for myself.

Disable Go helper function in Kirby

(because of a conflict with Swooles Go function)

# index.php

<?php

// Add in the line below
define('KIRBY_HELPER_GO', false);

require __DIR__ . '/kirby/bootstrap.php';

echo (new Kirby)->render();

Edit October 2024:

I've found a better way to do this is to disable the Swoole library in the php settings.

I add the following to the PHP FPM configuration:

swoole.use_shortname = Off
swoole.enable_library = Off

With this in place, I don't need to disable the helper function anymore in the index.php file.

Nginx config changes

On the site at hand, click the dropdown "edit files" and further "Edit Nginx configuration". Add the two following lines before the location

…

rewrite ^\/(content|site|kirby)/(.*)$ /error last;
rewrite ^\/\.(?!well-known\/) /error last;

// and it continues like normal…
location / {………

Links to Kirby docs on the topics:

Nginx boilerplate config
Deactivating Kirby helpers