Why use a self-hosted service for a developer's blog? (and how to do it)
I have always used free blog services for my all my (failed) attempts to make blogs of different kinds. Although free services (like Blogger and WordPress) are perfectly fine for people who are starting on blogging and don't have a lot of knowledge of web development, for me it's a little bit cumbersome to have the restrictions that some of these services provide.
As a full-stack web developer, I like to be in charge of all aspects of my web applications (even such simple ones like a blog). Third-party services usually don't allow that. I also wanted to learn how to do the process by hand, so I can replicate this for potential big clients who might need it.
There's one big drawback for self-hosted blogs: You have to pay money for it. My past experiences with free services showed me that the freedom that I wanted must have some price, but I took the risk. Later on this post I will show some advantages of this kind of investments for developer's blogs.
So here starts my journey in order to have my own self-hosted blog. I'm documenting this process for future reference.
From now on, this will be a guide to setup a self-hosted blog in a Virtual Private Server (VPS) on DigitalOcean. Blog platform will be Ghost (free software blog platform over Node.js). General advice for getting a DNS domain will also be given (I personally recommend GoDaddy for this purpose).
It's recommended to invest for at least a year of VPS hosting, since DNS domains are usually billed annually.
If you are interested in having your own self-hosted blog (and follow this guide), the following requirements must be met:
- Have basic GNU/Linux terminal and web development knowledge
- Have access to a Credit Card and/or PayPal account
- Have some money to invest (domains are around USD10 to USD20 per year, basic VPS can cost up to USD60 per year)
Getting a Virtual Private Server (VPS)
DigitalOcean (DO for now on) is a VPS provider, that provides fast high-uptime low-cost servers for any kind of use. In this case, we will use them as web servers. In DO, a single VPS instance is called a "Droplet".
First, create an account on DO (for free), login on it. Get your Credit Card or PayPal account with enough funds and load them on DO (you can do so on Settings -> Billing menu). Now create a Droplet (on Create -> Droplet menu). Some recommended configs are the following:
- Operating System: Ubuntu 16.04 x64 (or the latest LTS available)
- Droplet Size: Standard USD5 per month (this is enough for our needs)
- Block Storage: No
- Datacenter Region: NYC1 or SFO2 (depending on your location)
- Additional Options: Enable Monitoring only
- SSH Keys: Add your Git SSH Key (optional)
Now create your Droplet, in a few seconds it will be available and ready to use. You will get an IPv4 address (and a root password, if you chose not to add a SSH Key) in order to access it.
You can use PuTTY for Windows or the GNU/Linux terminal to access your VPS. Remember that Droplets don't offer a desktop environment by default (and they don't need to for these kind of uses). An easy terminal command can connect you to the server:
(Remember to change
188.8.131.52 with your Droplet's IPv4 address)
Once you're inside your droplet, you can configure some basic parameters to get things up and running. The following DO tutorial can help you to get things configured quickly, or if you like a TL;DR version, run the following commands in your new Ubuntu Droplet:
adduser mybloguser sudo usermod -aG sudo mybloguser su - mybloguser sudo ufw allow ssh sudo ufw allow http sudo ufw allow https sudo ufw enable
Now install Nginx as Web Service:
sudo apt-get update sudo apt-get install -y nginx
Install MySQL as Database Service:
sudo apt-get update sudo apt-get install mysql-server mysql_secure_installation
Install Node.js 8.x:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y build-essential nodejs
Install Ghost as our blogging platform (click here for a more detailed tutorial):
sudo npm i -g ghost-cli sudo mkdir -p /var/www/ghost sudo chown mybloguser:mybloguser /var/www/ghost cd /var/www/ghost ghost install
(follow the Ghost CLI instructions in order to setup your blog installation)
To start using your blog, enter
http://184.108.40.206 (or your Droplet's IP address) in your web browser. The blog admin panel can be accessed from
http://220.127.116.11/ghost in your browser.
Now we have our blog installed! But it's only accessible through our public IPv4 address (that no one will ever remember). In order to avoid this, we're going to get a super catchy DNS domain in order to increase visitors.
Get a DNS domain
Steps may highly vary acording to the DNS domain registrar of your choice. I chose GoDaddy for this purpose since they offered me a good deal for my current .info domain (as a first-time client). GoDaddy can be payed either with Credit Card or PayPal, and regular domains can cost between USD10 and USD20 per year.
Remember to choose a super catchy domain name in order to get more visitors!
Once you get your domain, remember to make the domain's NS records are pointing to DO (in your domain registrar's panel):
ns1.digitalocean.com ns2.digitalocean.com ns3.digitalocean.com
In your DO account, add your new domain under Networking -> Domains menu and create the following records:
A record -> @ -> directs to your Droplet IP A record -> www -> directs to your Droplet IP
You can configure more DNS records on this menu, you can check this tutorial for more info in order to do so.
Now you have a super catchy domain linked to your site! Start your blogging carreer and share your link with your friends.
Some useful advice
This might be useful for first-time bloggers:
- Install a super fancy blog theme in order to get more attention from your visitors
- Remember to post often enough to get your visitor's attention
- In case of making a developer's blog or a pseudo-portfolio, remember to add your most relevant projects as a Page Post, also posting a part of your resume could help you to get more attention from IT recruiters
That's all folks! Leave a comment or share if you like this content.