I agreed to give a talk at CapBUG on setting up and using Octopress to create a blog. Octopress uses Jekyll to let you create the pages and framework for a static website locally and then deploy the web site to a remote web server. You can find a copy of the presentation here
As Brandon Mathis’ tagline on the Octopress site says, this is “A blogging framework for hackers.” Fortunately I’d set up Octopress on Mac OS X Mountain Lion and understood how it worked. However I had never used OpenBSD or setup an OpenBSD system. So I decided to use my dilemma as a learning experience! Please don’t view this as a master class in setting up Octopress but more the public stumblings of a misguided soul! Here is what I learnt…
Creating An Open BSD Virtual Machine
I created an OpenBSD 5.2 virtual machine using the install52.iso in VMware Fusion v5. I set the Fusion VM configuration to be:
OS=Other; Version=FreeBSD 64-bit; Memory=256MB; Network Adapter=Shared With My Mac; Hard Disk=10GB in 2GB splits
I accepted most of the defaults for the BSD installation:
default keyboard layout; hostname=yourhostname; network interface=em0; IPv4=DHCP; IPv6=none; root password=password; sshd=yes; ntpd=yes; ntp server=default; X Window=yes; xdm=no; console to com0=no; user=octopressuser; full name=full name; octopressuser password=password; disable sshd root=yes; TZ=US/Eastern; root disk=sd0; DUIDs=yes; MBR has invalid signature therefore Use whole disk=yes; Layout=Auto; Sets location=cd; sets media=cd; pathname to sets=5.2/i386; Sets=All except bsd.mp; Set time
Setting Up An OpenBSD Workstation For Octopress
As mentioned above, I have not set up an OpenBSD (nor FreeBSD) system before and I wanted to use this exercise as a learning experience. My familiarity with other operating systems made me realize that for this exercise to be successful I had to understand how the package management system worked in OpenBSD. So it was off to Chapter 15 in the OpenBSD FAQ to read up on The OpenBSD Packages And Ports System.
As with most exercises of this nature Google is your friend. While there is no definitive guide to setting up Octopress on OpenBSD that I could find, there are a number of blogs that helped to provide clues as to what I should do and they are listed below in the bibliography.
Octopress uses Ruby to perform its magic, and uses Git and Rsync to help it function. As an OS X user and part time Ubuntu Linux distribution user I have a world view that involves using Bash and most probably doesn’t fit with that of a typical OpenBSD user, so my apologies in advance.
Throughout this text I’ll try to use the following conventions: root is the OpenBSD root user; octopressuser is the normal user you created when setting up the system.
Setting Up The Root And User Environment
To simplify the use of the package management system I assigned the PKG_PATH variable in .profile for both root and octopressuser. Insert the following into .profile:
PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/5.2/packages/i386/
export PKG_PATH
Ironically while writing this blog post I encounted errors when I used Octopress to generate this post. Chapter 10 of the OpenBSD FAQ on character sets revealed that the errors were caused because of the way OpenBSD handles UTF-8 character sets. To prevent the errors occuring I inserted the LC_CTYPE variable into .profile for both root and octopressuser:
export LC_CTYPE=“en_US.ISO8859-1”
Log in as root
Log in as root to perform the next steps. Remember to set up the PKG_PATH and the LC_CTYPE variables as described above.
Bash
I installed Bash as the default shell for both root and the user with the following commands:
1 2 3 |
|
Git, etc.
Octopress is downloaded from the Github repository so Git needs to be installed. Installing Git also installs Rsync. One of the clues I found via Google implied that installing Wget, Autoconf and Automake would also be a good idea. So I ran:
1
|
|
The -i and -v attributes to add_pkg make command interactive and verbose. In this instance when prompted I installed git-1.7.6p4, rsync-3.0.9 (rather than rsync-3.0.9-iconv), autoconf-2.69 and automake-1.9.6p10.
Another clue I found via Google implied that I should also install Patch, Gcc, Readline, Libxml2, Libxslt, Diffutils, Make, Libtool and Bison. (Unfortunately I’ve lost the original clue so here is a similar clue.) So I ran:
1
|
|
(However Patch, Diffutils and Make were not found and did not install. But the Octopress installation seemed to progress okay without them…)
Ruby
Octopress requires Ruby v1.9.3 so using this clue and this clue I ran the following command:
1
|
|
And set the appropriate links with:
1 2 3 4 5 6 7 8 |
|
Sudoers
To simply installation when logged in as octopressuser later in the process, I added octopressuser to the sudoers file using:
1
|
|
And inserted:
octopressuser ALL=(ALL) SETENV: ALL
Installing, Configuring and Using Octopress In The Octopress User’s Account
Octopress uses a directory structure within a user’s account to hold the website source files and the generated website content that will be deployed to the web server. So for the final stages of setting up Octopress you log out of the root account and log into the octopressuser account. The process below is based on the steps described on the Octopress web site for installing under OS X.
Log In As octopressuser
Log in as octopressuser to perform the next steps. Remember to set up the PKG_PATH and the LC_CTYPE variables as described above.
Get Octopress From The Github Repositories
Download Octopress from Github into the directory of your choice. In this example I have used a directory called blog:
1 2 |
|
Set Up The Octopress Directory Structure
Enter the blog directory and install the Gem bundles. Due to my lack of experience with OpenBSD and setting permissions, I forced the command to work by using Sudo:
1 2 |
|
Then to get the Bundle command to run I had to include its full path:
1 2 |
|
Setting Up The User Environment
For this example I have choosen to deploy the Octopress generated content to the web server using Rsync. For Octopress to be able to deploy the content, SSH key-based passwordless login must be set up. As this site is hosted by Dreamhost I followed their instructions for creating and deploying the SSH public key. Create the SSH keys as follows:
1 2 |
|
Copy the public key to your web server. In this example the web site is called example.com and the user user administers the web site:
1 2 |
|
Then on the example.com web server as user, assuming it’s a Linux distribution:
$ mkdir .ssh
$ cat id_rsa.pub >> .ssh/authorized_keys
$ rm id_rsa.pub
$ chmod go-w ~
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys $ logout
Configure Octopress Deployment
Now back on the OpenBSD system, Octopress is configured to deploy to the web server using Rsync. Edit the Rakefile file in the blog directory:
1 2 |
|
For example, set the following parameters:
ssh_user = “user@example.com”
ssh_port = “22”
document_root = “~/example.com/“
rsync_delete = true
rsync_args = “” # Any extra arguments to pass to rsync
deploy_default = “rsync”
Configure The Octopress Blog
Now the blog needs to be configured by setting the parameters in the _config.yml file:
1 2 |
|
For example, set the following parameters:
url: http://example.com
title: My Octopress Blog
subtitle: A blogging framework for hackers.
author: Your Name
simple_search: http://google.com/search
description: A blog to demonstrate the installation and use of Octopress.
Creating A Blog Post
To create a blog post and edit that post, do the following:
1 2 |
|
The post file will be in the ~/blog/source/_posts/ directory preappended with the date you created the file. For example, to edit the file:
1
|
|
Deploying A Blog Post
If you are happy with your Markdown skills you can now deploy the post you have created:
1 2 3 |
|
Previewing A Blog Post
Octopress does allow you to preview blog posts before you deploy them. So to do that on the OpenBSD system I installed Firefox and launched X Windows:
1 2 |
|
Once X Windows was running I ran the following commands in the X Terminal:
1 2 3 4 |
|
I then used Firefox to view the URL http://localhost:4000
Bibliography
Octopress
Getting the OpenBSD 5.2 ISO
The OpenBSD Packages And Ports System
OpenBSD Character Sets
Installing Bash Under Open BSD
Installing Ruby 1.9.3
How To Install RVM Ruby FreeBSD
Installing Chef Client On OpenBSD
Building Ruby On OpenBSD From Source
Dreamhost SSH
Deploying Octopress With Rsync
Configuring Octopress
Blogging Basics With Octopress