Getting started with Jekyll on CentOS 7
It’s not quite as easy to get up and running with Jekyll as the Quick Start Guide makes it sound. But it’s not super difficult either – if explained from one human to another.
Here’s how I got Jekyll working on a vanilla CentOS 7 instance.
Installing some necessary packages
Before we can install Jekyll using Rubygems, we need a few packages which aren’t with us by default. One comes from the Fedora EPEL repository, so let’s enable that first:
yum install epel-release
I love how easy this has become since CentOS 7! Next, some packages. We’ll need Ruby and the developer extensions. We also need a web server, so I’ll choose Apache – but I understand that others work just as well.
What this boils down to are the following packages:
yum install ruby ruby-devel nodejs httpd
Great! Now that Ruby is working, let’s install Jekyll via Rubygems:
gem install jekyll
This could take a moment, be patient. When it’s finished, let’s put Jekyll to work.
Creating and previewing a test site
Let’s call our new test site “test”. I’m assuming you’re in your home directory from which usually no web files shall ever be served – but thanks to Jekyll we can make that happen for local testing purposes. The following command will create a brand new site in the current directory:
jekyll new test New jekyll site installed in /root/test.
Excellent! But how do we get to see it? Well Jekyll has created a directory called “test” for us. Let’s enter it and preview the site:
cd test jekyll serve Configuration file: /root/test/_config.yml Source: /root/test Destination: /root/test/_site Generating… done. Auto-regeneration: enabled for ‘/root/test’ Configuration file: /root/test/_config.yml Server address: http://127.0.0.1:4000/ Server running… press ctrl-c to stop.
What Jekyll is trying to say is that IF we are building this on a system with a desktop environment, we could open a web browser and enter http://localhost:4000 now to preview the site. Jekyll spawns a web server on port 4000 so that we can see any changes we’ve made since last time without affecting a live site.
Sadly this approach doesn’t work on remote servers though, at least not for me: port 4000 on a remote server simply did not respond. Regardless, on the local sever it was working just fine, and we should see a picture like this:
That’s a good start – let’s put the site live so that our web server can show it to the world!
Building the site
Press CTRL-C to stop the preview serving procedure and ask Jekyll to create this site in our default web directory. In CentOS that’s /var/www/html. Mine is empty so I’ll create the site there using
jekyll build --destination /var/www/html Configuration file: /root/test/_config.yml Source: /root/test Destination: /var/www/html Generating… done. Auto-regeneration: disabled. Use –watch to enable.
Nicely done! Now let’s surf to http://localhost (without the 4000 at the end), and the local machine should see this content served up fresh just like any other website. Remote computers should use either the IP address or a domain resolving to it (say http://220.127.116.11).
Now that you know how it works, enjoy using Jekyll!