Set up a blog with Ghost

Set up a blog with Ghost

ยท

3 min read

Let's say you are doing freelance work for a client who wants to launch a blog. While Hashnode is great, it's probably not adapted in every case. Especially for non-developers and if you need high customization also.

Here I propose to deploy a blog using Ghost.

Prerequisites:

Ghost is running on Node.js, it is a modern and very straightforward solution to anyone willing to start a blog. The Ghost developers also offer hosting on their website, if you want more info: ghost.org

Now here is the process. First, we create a folder blog and a script start.sh. Then we run the script.

mkdir /blog && cd /blog
echo docker run -d --name ghost -p 2368:2368  -e url=http://yourdomain.com -v /blog/content:/var/lib/ghost/content --restart=always ghost:alpine > start.sh
chmod +x start.sh
./start.sh

Finally, have a server in Nginx in front of it:

server {
    server_name my.blog.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/my.blog.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/my.blog.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = my.blog.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name my.blog.com;
    listen 80;
    return 404; # managed by Certbot
}

You can notice I use Certbot, if you don't know about Certbot, check my article:

Now you can visit yourdomain.com and see your blog in action.


Photo by Tandem X Visuals on Unsplash

Did you find this article valuable?

Support Sonny Alves Dias by becoming a sponsor. Any amount is appreciated!

ย