Knowledgebase

Creating a Jekyll Blog on CentOS Print

  • 0

Jekyll is a good alternative to WordPress. It doesn't require any databases and it works with a language many are familiar with (Ruby on Rails). Jekyll is static and requires little memory, which means it can run on the 768MB Rcs instance for low traffic.

##Step 1: Installing Ruby on Rails

First, log on to your instance/server and update your packages. Please make sure you're logged in as the root user.

yum update -y

Now, let's grab Ruby's package manager (RVM).

cd /tmp
curl -sSL https://get.rvm.io > ruby_install
chmod 755 ruby_install
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 
./ruby_install stable --ruby 

This will take a while, as everything is compiled. Please allow for a few minutes and once you've been returned to the prompt, continue to the next step.

Let's install Ruby now.

rvm install ruby
rvm --default use ruby    

Awesome! Now, we need to get NodeJS as it is a dependency of Ruby on Rails.

yum install epel-release -y
yum install npm nodejs -y

##Step 2: Installing Jekyll

This part is quite easy. Simply execute the following to install Gem dependencies of Jekyll:

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 the title of your blog.

jekyll build
cd /home/jekyll/
jekyll new myblog
chown jekyll:jekyll -R myblog/

And finally, let's start it:

bundle exec jekyll serve --detach
exit

##Step 3: Creating a 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:

yum install nginx -y

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.

Now, open up /etc/nginx/nginx.conf with your favorite text editor. Comment out anything from lines 38 to 57 by adding a # symbol behind the lines. Save the file, then execute the following to restart Nginx:

systemctl restart nginx

##Step 4: Configure the firewall

Port 80 hasn't been opened to the public yet - let's fix that. Please run the following:

firewall-cmd --zone=public --add-port=80/tcp --permanent

And reload for the effects to take place:

firewall-cmd --reload

##Writing posts

Every time you wish to write a post, log in to your server. Then, drop privileges:

su jekyll
cd ~/myblog
cd _posts

To create a post, create a file with the following format:

year-month=day-yourposttitle.markdown

For example: 2017-1-1-helloworld.markdown

Populate the file with Markdown content. You 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!

Jekyll is a good alternative to WordPress. It doesn't require any databases and it works with a language many are familiar with (Ruby on Rails). Jekyll is static and requires little memory, which means it can run on the 768MB Rcs instance for low traffic. ##Step 1: Installing Ruby on Rails First, log on to your instance/server and update your packages. Please make sure you're logged in as the root user. yum update -y Now, let's grab Ruby's package manager (RVM). cd /tmp curl -sSL https://get.rvm.io > ruby_install chmod 755 ruby_install gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 ./ruby_install stable --ruby This will take a while, as everything is compiled. Please allow for a few minutes and once you've been returned to the prompt, continue to the next step. Let's install Ruby now. rvm install ruby rvm --default use ruby Awesome! Now, we need to get NodeJS as it is a dependency of Ruby on Rails. yum install epel-release -y yum install npm nodejs -y ##Step 2: Installing Jekyll This part is quite easy. Simply execute the following to install Gem dependencies of Jekyll: 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 the title of your blog. jekyll build cd /home/jekyll/ jekyll new myblog chown jekyll:jekyll -R myblog/ And finally, let's start it: bundle exec jekyll serve --detach exit ##Step 3: Creating a 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: yum install nginx -y 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. Now, open up /etc/nginx/nginx.conf with your favorite text editor. Comment out anything from lines 38 to 57 by adding a # symbol behind the lines. Save the file, then execute the following to restart Nginx: systemctl restart nginx ##Step 4: Configure the firewall Port 80 hasn't been opened to the public yet - let's fix that. Please run the following: firewall-cmd --zone=public --add-port=80/tcp --permanent And reload for the effects to take place: firewall-cmd --reload ##Writing posts Every time you wish to write a post, log in to your server. Then, drop privileges: su jekyll cd ~/myblog cd _posts To create a post, create a file with the following format: year-month=day-yourposttitle.markdown For example: 2017-1-1-helloworld.markdown Populate the file with Markdown content. You 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!

Was this answer helpful?
Back

Powered by WHMCompleteSolution