How to run a Ghost blog on Laravel Forge
Since I have a Laravel Forge account to help me manage my server, I wanted to host this Ghost blog in it too, and it's relatively easy.
Create a server on Forge
I'm using a Stardust instance in Scaleway since it keeps my operating costs relatively low. It costs around $2.2/month(€0.0025/hour).
Create a new site with /ghost/current path as Web Directory, and set up a new SSL certificate with LetsEncrypt.
Setup Nginx
Edit the site Nginx configuration.
Replace index index.html index.htm index.php; with index index.js index.html index.htm index.php;
Replace the location block from:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
to:
location / {
proxy_pass http://127.0.0.1:2368;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
Add a MySQL database
Create a new database for Ghost.
Install Ghost
Connect to the server via SSH.
ssh forge@IP_ADDRESS
Install Ghost CLI.
sudo npm i -g ghost-cli
Remove your existing ghost directory.
cd oliver.mx
sudo rm -rf ghost
Make a ghost directory and install Ghost.
mkdir ghost && cd ghost
ghost install
The installation process looks like this:
Enter your blog URL: https://oliver.mx
Enter your MySQL hostname: 127.0.0.1
Enter your MySQL username: forge
Enter your MySQL password: [Forge created Database password]
Enter your Ghost database name: ghostblog
# Answering no will skip the SSL set up as well
Do you wish to set up Nginx? n
Do you wish to set up "ghost" mysql user? n
Do you wish to set up Systemd? Y
Do you want to start Ghost? Y
Congrats! Your new Ghost blog is alive.