Setting up Jekyll with Dreamhost

Intro

Huh? Wait? Isn’t TheCoatlessProfessor powered by Wordpress?

Well, it use to be. I grew weary of hearing complaints about TCP being unavailable or just slow. So, I started looking for alternatives. I’ve been a huge supporter of RMarkdown as of late (see: Reproducible Research). So, part of my needs for the next iteration of TCP was the easy of publishing with RMarkdown. Why? I can’t stand to use WYSIWYG editors after having spent so much of my life using some form of literate programming. Thus, I settled upon using Jekyll… Little did I know what kind of headache I had just willing entered.

Prerequisites

The instructions below are contigent upon having a Dreamhost account. That is not to say this isn’t applicable for other hosting providers, but the majority of the process described is meant for Dreamhost.

If you have a VPS or dedicated account, this is about ten times simplier. Part of the battle with Dreamhost on a shared account is the fact that you lack sudoer access from shell. Simply put, installs are a pain in the neck.

I also assume that you have installed git locally and on your server.

For those operating on Windows, I use Cygwin. For OS X and Linux, git is installed by default.

Install Ruby on the Server

On Dreamhost, the default ruby version is Ruby version: 1.8.7, which is woefully out of date and also is too low to run Jekyll. To give you an idea just how out of date it is, 1.8.7 was released on May 31st, 2008 and exited its supported life cycle on June 30th, 2013.

Attempt #1: Compile Ruby from Source and place in a local directory.

I initially tried to build ruby just using compiles with a local directory. e.g.

wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.0.tar.gz
tar -xzvf ruby-2.2.0.tar.gz
cd /ruby-2.2.0
./configure --prefix=/home/<user>/ruby
make && make install

But, alas, compile woes.

Attempt #2: Install using a package manager

So, I looked elsewhere… I stumbled across RVM, which promised easy installs, upgrades, and uninstalls.

Downloading and installing the package manager is straight forward:

# Add the public key
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Install only the package manager
\curl -sSL https://get.rvm.io | bash -s stable

At this stage, I jumped up and down thinking I had found the panacea for my ruby compile woes. But, when issuing:

rvm install ruby-1.9.3

The command failed as I was prompted to upgrade the system libraries via apt-get.

Attempt #3: Install using a binary with the package manager

So, I sat back and thought about a different way to attack the problem. I realized that I didn’t need to create my own binaries for compiling, but I probably could use binaries someone else compiled.

We will still need to download and installing the package manager:

# Add the public key
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Install only the package manager
\curl -sSL https://get.rvm.io | bash -s stable

Now, the to access the binary we need:

rvm mount -r https://rvm.io/binaries/{OS_NAME}/{OS_VERSION}/{RUBY_VERSION}.tar.bz2 --verify-downloads 1

To obtain the OS name and OS version the server is running, use:

OS=$DISTRIB_ID
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$DISTRIB_RELEASE

echo "OS NAME: $OS, VERSION: $VER, ARCHITECTURE: $ARCH"

To find the binary that corresponds to the entry, see: https://rvm.io/binaries/ or just use the above mount path naming scheme.

As of this writing, Dreamhost is using Ubuntu 12.04 x86_64. Thus, we would use:

rvm mount -r https://rvm.io/binaries/ubuntu/12.04/x86_64/ruby-2.1.5.tar.bz2 --verify-downloads 1

Note: The ruby binaries available for Ubuntu 12.04 range from 1.9.3 - 2.1.5.

(Bonus) Attempt #5: Install using a package manager with autolibs disabled

In the event dreamhost avoid upgrading 12.04 to the point that it becomes obsolete and the binaries disappear, here is another option. This option isn’t necessarily recommended. But, it seems to work for all of Jekyll’s needs.

We will still need to download and installing the package manager:

# Add the public key
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# Install only the package manager
\curl -L https://get.rvm.io | bash -s — –autolibs=read-fail

# Disable autolibs
rvm autolibs disable

# Install the latest verison
rvm install ruby-2.2.0

Initialize Ruby

Now that ruby is installed, we need to: 1. set the installed version to be default and 2. initialize it

To find out what ruby verisons are installed type:

rvm list

In my case, I installed version 2.1.5, and thus to set the default I would write:

rvm alias create default ruby-2.1.5

To initialize the ruby version, then use:

rvm default

Installing Jekyll

At this stage, we’re able to use gem:

gem install jekyll

And jekyll is now installed! Rejoice and start experimenting….

Interested in the deployment configuration I’m using?

See [Configuring Jekyll]({% post_url 2015-07-12-configuring-jekyll %}).

comments powered by Disqus