Set up Statamic on SpinupWP
I have a nice Linode (affiliate link) server and managed by SpinupWP (affiliate link) and I host several WordPress sites on it, including my personal sites.
I have been looking for alternatives to WordPress and Statamic is the one I would love to try the most. The only caveat is that I don't want to set up a new server to host a Statamic site, especially I just wanted to explore and play around a bit.
The below is how I created a new site on this current server.
Create a blank new site on SpinupWP
When adding a new site to your SpinupWP server, you can choose to "Not install any files" and that's what I wanted. I created a Database with this site but at the moment, this Statamic site is not using a Database.
Install Statamic on this new site
The server set up by SpinupWP didn't come with the Statamic Cli so we need to install it. I installed with the site user so I have to access the cli tool via ~/.config/composer/vendor/bin/statamic
.
SpinupWP hosts your site in ~/files
and it is the default public folder.
So I cd
to ~/files
and my install command is like ~/.config/composer/vendor/bin/statamic new statamic
. It then created a statamic
folder in ~/files
.
After following all instructions on the cli screen, I then went to the site Settings on SpinupWP and set the Public Folder to /statamic/public/
(with the prefix /sites/next.1fix.io/files
that you cannot change).
Nginx config changes
The most tricky part is to identy what needs to be added/changed to the Nginx config.
In the default Nginx config of the site, the following block has to be removed/commented out:
location / {
try_files $uri $uri/ /index.php?$args;
}
Becasue Statamic will add its own location block.
Then I split the Nginx config recommanded by Statamic into two files:
server/statamic.config
set $try_location @static;
if ($request_method != GET) {
set $try_location @not_static;
}
if ($args ~* "live-preview=(.*)") {
set $try_location @not_static;
}
location / {
try_files $uri $try_location;
}
location @static {
try_files /static${uri}_$args.html $uri $uri/ /index.php?$args;
}
location @not_static {
try_files $uri /index.php?$args;
}
location = /favicon.ico { access_log off; log_not_found off; }
#location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
#location ~ \.php$ {
# fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ /\.(?!well-known).* {
deny all;
}
Note that I have commented out a certain blocks to prevent conflicts with SpinupWP.
location/statamic.conf
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params
With them, after testing the config and reload Ningx, the Statamic is up and running on the domain https://next.1fix.io.
I will soon knowing if things are working for me or not. And I'll report back here.