Table of contents
This is post 3 of 3 in the series "Blog Website"
- Blog Website - Part 1: Website
- Blog Website - Part 2: Web Component Library
- Blog Website - Part 3: Deployment & Hosting
Domain & SSL Certificates (Namecheap)
A few days before purchasing my domain name, I encountered Namecheap advertising multiple times. Honestly, I liked it. Once I decided to host my website, I recall the advertising in the blink of an eye. It looks like advertising really works.
The one thing was missing. For a website to be secure, I needed SSL certificates. As I already purchased the domain name on Namecheap, I bought SSL certificates in the same place.
Hosting (Digital Ocean)
A good friend of mine hosted his website on the Digital Ocean. I asked him whether he liked it. He told me that I should use it without any doubt. I gave it a try, and I haven't encountered any issues. I like it. It's easy to use and not too expensive.
Server (Nginx)
I was thinking a lot about what server to use. And looks like the most popular choice is Ngnix. As I used it before I decided to go with it once again. The developers who worked with Nginx won't let me lie; it's very flexible and easy to use. Moreover, it covers all my needs.
To improve the performance of my website, I used Nginx compression. In other words, I gzip static files. I significantly reduced the sizes of transmitted data with Nginx compression.
It is important to note that I build everything on my local machine and only then deploy the bundles. In this way, I can purchase a less expensive server and won't have any issues with it.
Forever
I used the forever
node package to run the website continuously.
And yes, I know what you'll say: pm2
is in demand and has more features.
But I decided to use forever
at that time.
Firewall
Up until that moment, I had never configured the firewall. However, the time has come. Truth be told, I spent a reasonable amount of time learning firewall configurations, but that was worth it. I've configured my firewall on my server and now know how to do it.
Sitemap
I had to generate a sitemap.xml
file to index my blog with
Google Search Console whenever I added a new article or any other page.
I wrote a node.js script that was responsible for generating a sitemap
file and included this script in my npm scripts. Now, the sitemaps
are generated by default whenever I push new changes, and I don't have
to do anything manually.
Article Generation Script
Each article contains many factors such as folder, id, name, description, status, configs, etc. It's hard to keep in mind everything that needs to be done once you want to add a new article. To simplify this, I wrote a script in bash that does everything for me. It asks me all the details necessary for article creation and only then creates the article.
Deployment script
As I mentioned, there are many details whenever I make changes to the project. I have to commit and push the changes separately for the blog and each git submodule. Before I push the git changes, I have to build all necessary bundles. I must pull them on the server, redeploy, and restart Nginx with the forever module. And sometimes, I just want to deploy a simple change. Fortunately, I implemented a bash script that does all this for me. Now, when I want to provide any change, I just run one command, and everything is deployed on the server.