How to install Jekyll on cPanel shared hosting account

First thing first

Requirments

This method was tested on bytii.cloud using Managed Hosting package
and you can also replicate it using any hosting service that have:

cPanel
CloudLinux
Litespeed webserver

and provides you as well with the hosting package

SSH access
Ruby selector

I like to use μ micro Editor

curl https://getmic.ro | bash


Let’s get started!

First login to your cPanel hosting account.
We will need to setup Ruby virtual environment.

In cPanel » software » ruby cPanel

Setup an App

Setup new Ruby App Ruby App

We will configure Ruby version to 2.5,
set working and publishing folders jekyll_exp - 011.ninja/blog_exp
and click the setup button.

jekyll Folders

  • The App Directory will be our working folder (virtual environment) and the App Domain URI folder will be used for publishing (site folder).

Entering virtual environment

Now we have an App. It will generate a command for entering to virtual environment.

In our case it will be

source /homefolder/gilad/rubyvenv/jekyll__exp/2.5/bin/activate


since jekyll_exp is our working folder.

command for entering to virtual environment

To run this command we will need to login to our hosting account using ssh.

ssh cpanelusername@yourdomain.com


Use your password, then change directory to your home folder cd ~ (if you are not already there).

Enter the virtual environment with you app command.

source /homefolder/gilad/rubyvenv/jekyll__exp/2.5/bin/activate


Now you will see in your terminal something like this …

 (jekyll_exp:2.5)[cpanelusername@yourhostserver ~]$


Verifing App is working

If you already installed jekyll this will be quite familiar

cd jekyll_exp


ls jekyll_exp


Now we can see the public folder where the ruby app is running.

The result will be published to our publishing folder 011.ninja\blog_exp

If you will surf to yourdomain.com/blog_exp (as in this example)

You will be able to see something like this:

working Ruby App

  • The Ruby App is live and working!

Now that we have Ruby virtual environment installed on the cPanel account we can install Jekyll.

Let’s install and deploy Jekyll !

We will run this command from jekyll_exp folder.

gem install bundler jekyll bigdecimal


Now we will create a new Jekyll project.

jekyll new blog_dev


Enter its folder.

cd blog_dev/


Now we are able to see Jekyll installed in the blog_dev folder.

(jekyll_blog:2.5)[gilad@myserver blog_dev]$ ls
404.html  about.markdown  _config.yml  Gemfile  Gemfile.lock  index.markdown  _posts


Next step we want to take is to build and run the Jekyll server.

Run with

bundle install

And then deploy with

JEKYLL_ENV=development jekyll build --baseurl '/blog_exp' --destination ~/jekyll_exp/public --watch --trace


It is important to run this command from within the Jekyll project folder

The environment value JEKYLL_ENV= allows you choose development or production mode.

We build Jekyll with base url as /blog_exp and we pull the data from /jekyll_exp/public

all changes in Jekyll project folder will be generated to /jekyll_exp/public

That’s it !

Enjoy your super fast Jekyll site.