Using a Different System?
-
Creating a Jekyll Blog on CentOS 7
Jekyll is a great alternative to WordPress for blogging or sharing content. It doesn’t require any databases and it is very easy in which to write new posts. Jekyll is static and requires little memory, which means it can run on the 768MB or even 512MB Vultr instances with low traffic.
Step 1: Installing Ruby
First, log into your server, then execute these commands:
sudo apt-get update
sudo apt-get install ruby-full make gcc nodejs build-essential patch
Step 2: Setting up Jekyll
This part is quite easy. Simply execute the following to install Jekyll and its dependencies using Gem:
gem install jekyll bundler
Now, create a user for it:
useradd jekyll
We need to create the blog now – feel free to change “myblog
” to anything you’d like.
jekyll build
mkdir /home/jekyll
cd /home/jekyll
jekyll new myblog
chown jekyll:jekyll -R myblog/
And finally, let’s start it:
cd myblog
bundle exec jekyll serve --detach
Step 3: Creating an Nginx proxy
Because Jekyll runs on port 4000, visitors will be required to add the port into the URL, which isn’t very good. We’ll install Nginx, which will forward requests from port 80 to 4000.
First, get the package:
sudo apt-get install nginx
Now, open up your favorite text editor to /etc/nginx/conf.d/jekyll.conf
and paste the following:
server {
listen 80;
server_name myblog.com;
location / {
proxy_pass http://localhost:4000;
}
}
Change myblog.com
to your website domain, and save.
Execute the following to restart Nginx:
systemctl restart nginx
With your DNS provider, direct your domain to your server’s IP address. If you did all of this correctly, you will be able to see your Jekyll blog at your website domain!
Writing posts
Every time you wish to write a post, log into your server. Then, switch to the jekyll
user:
su jekyll
cd ~/myblog
cd _posts
To create a post, create a file, named with the format “year-month-day-yourposttitle.markdown
“. For example:
2017-1-1-helloworld.markdown
Populate the file with Markdown content, and you will have completed writing a post.
Conclusion
In this article, you setup a Jekyll blog. Now, all you have to do is focus on your content. Good luck!
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article