Millions of bloggers around the world are searching for "THE" perfect tool to write and share their knowledge or ideas. But when it comes to blogging, they are zillions of tools out there.
For me, I found that Ghost is the way to go. It beautifully designed, simple to use, simple to set up and has a large community to support if things are not going well.
In this article, I will show you how you can install Ghost for yourself using Docker and you will be able to manage every step of your blogging process.
What is Ghost
Ghost is a powerful app for professional publishers to create, share, and grow a business around their content. It comes with modern tools to build a website, publish content, send newsletters & offer paid subscriptions to members.
When to use Ghost
If you want to take your blog to the next level, you definitely consider using Ghost for blogging. Even though WordPress is a very popular blogging platform, I prefer the flexibility and ergonomic of Ghost.
It has plenty of features and never-ending updates. There are 2 methods of using it, Subscription or Self-hosted.
In this blog post, I will describe in step by step, how you can install it with docker, on your own server. Personally, I use a VPS that I bought at a fair price at SSDNode, and it runs really well.
Running Ghost with Docker
In the snippets below, replace domain-name by the real domain you have bought.
Primary, you need to create a folder where you will locate your docker-compose.yml
file.
Navigate to the /var
folder in your Linux server.
cd /var
Create a folder for your docker instance.
mkdir ghost
Move in that folder
cd ghost
Create a docker-compose.yml
file in that folder
touch docker-compose.yml
Open the newly created file in your terminal, using vim.
vim docker-compose.yml
Paste the following docker compose configuration
version: '3.3'
services:
blog:
image: ghost:5.53.3
container_name: ghost-blog
restart: unless-stopped
ports:
- '2368:2368'
volumes:
- './ghost/content:/var/lib/ghost/content'
environment:
url: https://domain-name.com
database__client: mysql
database__connection__host: database
database__connection__user: ghost
database__connection__password: admin
database__connection__database: ghost
NODE_ENV: production
depends_on:
- database
database:
image: mysql:8.0
container_name: ghost-db
restart: unless-stopped
ports:
- '3306:3306'
volumes:
- './ghost/data:/var/lib/mysql'
environment:
MYSQL_ROOT_PASSWORD: root-pass
MYSQL_USER: ghost
MYSQL_PASSWORD: admin
MYSQL_DATABASE: ghost
About the environment section
...
environment:
url: https://domain-name.com
...
The URL element corresponds to the domain (https://domain-name.com
) name you need to register for your blog — i.e. the URL where your blog can be reached by people around the world. I use Namecheap as a domain name provider, but, there are zillions of alternatives on the internet.
About the image section
...
services:
blog:
image: ghost:5.53.3
...
I used a random version, but you can use whatever you want from the tags available. (I recommend using the latest
tag if you want to have recent updates from ghost, without deleting your docker images).
Now you can run your Ghost services.
docker-compose up -d
Setting Up Nginx Reverse Proxy
Before creating the nginx reverse proxy configuration, you should pay a domain name where your blog can be reached. As I mentioned earlier, you can use Namecheap or other alternatives. Domain names are usually cheap and can be registered in a few minutes.
In the snippets below, replace *domain-name* by the real domain you have bought.
After you have registered your new domain name, create a domain-name.conf
file in your Linux folder /etc/nginx/sites-available/
sudo touch domain-name.conf
open the file
vim domain-name.conf
Add the following configuration
server {
server_name domain-name.com;
access_log /var/log/nginx/domain-name.log;
error_log /var/log/nginx/domain-name.log error;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2370;
proxy_redirect off;
}
}
Enable this configuration by creating a symlink into site enabled directory
sudo ln -s /etc/nginx/sites-available/domain-name.conf /etc/nginx/sites-enabled/domain-name.conf
Reload nginx
sudo nginx -s reload
Setting Up Certbot Lets-Encrypt
Generate SSL certificate for your domain name
sudo certbot --nginx -d domain-name.com
Reload Nginx
sudo nginx -s reload
Once all these configurations are done, you can reach your blog at domain-name.com
I hope you enjoyed reading this, and I'm curious to hear if this tutorial helped you. Please let me know your thoughts below in the comments. Don't forget to subscribe to my newsletter to avoid missing my upcoming blog posts.
You can also find me here LinkedIn • Twitter • GitHub or Medium
Ending
In conclusion, Docker makes the process of installing Ghost Blog simple and easy to manage. By following the steps outlined in this tutorial, you should be able to set up your own Ghost Blog smoothly and efficiently.
Remember to regularly update your Docker and Ghost Blog to ensure the security and functionality of your blog. With the flexibility and control Docker offers, you can now focus on creating compelling content for your readers.