August 3, 2012

Second Crack and Webfaction

In the process of migrating scientifics to Second Crack over the past few days, I decided that it would be useful to publish a tutorial on how to get it running on Webfaction.

While the readme comes with fairly thorough instructions, there are some differences due to how Webfaction works. If you are on another web host and are having similar issues, some of these tips may help you get things running as well.

Installing Dropbox

Dropbox is not a necessary part of Second Crack, but it makes publishing to your blog much easier. In order to get Dropbox running, log into your server via SSH and follow the instructions from Dropbox.

As noted in the instructions, when you run the app for the first time you will be prompted to authorize your account. For security, I recommend setting up a secondary account on your server and then sharing your blog source folder (I will refer to this folder as Blog”) with that secondary account.

You will also want to upload the CLI python script to your home directory on your server (/home/username). Running the script with the command autostart” will set up your server to automatically start Dropbox so it is always running.

python autostart

Installing inotify-tools

Second Crack takes advantage of inotifywait (part of inotify-tools) to update your static files whenever Dropbox is updated. This is also optional, but without inotify-tools, your static files will only be updated whenever your cron runs the update script (more on cron later).

To install inotify-tools:

  1. Download the source from GitHub

  2. Extract and upload to your home directory (/home/username)

  3. Log in via SSH and change into the inotify-tools directory (using the cd command)

  4. Run the following commands to install (each step may take a few minutes):

     ./configure --prefix=$HOME
     make install

Install Second Crack Changes

After downloading Second Crack from GitHub there are a few changes that need to be made to the files.

  1. Rename config.php.example to config.php and open it in your favorite text editor.

  2. Input all your settings, making sure your paths are correct (replace username with your Webfaction username).

     Updater::$source_path   = '/home/*username*/Dropbox/Blog';
     Template::$template_dir = '/home/*username*/Dropbox/Blog/templates';
     Updater::$dest_path     = '/home/*username*/secondcrack/www';
     Updater::$cache_path    = '/home/*username*/secondcrack/cache';
  3. In order for Second Crack to run on Webfaction, you also need to make a change to engine/ Find all of the php commands, and change them to /usr/local/bin/php53. This allows Second Crack to run under PHP 5.3 rather than the Webfaction default of PHP 5.2.

  4. Move the files in the example-templates” folder to a folder called templates” inside your Blog” folder in Dropbox.

  5. Upload the whole secondcrack” folder to your home directory.

  6. Add the following to your cron on your server (crontab -e):

     * * * * * /home/*username*/secondcrack/engine/ /home/*username*/Dropbox/Blog /home/*username*/secondcrack

Now that everything is set up, you can publish your first post.

Publishing in Second Crack

The template for a blog post looks like this:

My draft title
Tags: tag1, tag2
Type: post

Draft content.

A few notes on the formatting: the dividing line must be the same length as your title and tags are optional.

Create a drafts” folder in your Blog” folder and save the post as a .md file. If everything is set up, a _previews” folder will be created inside drafts” containing an HTML file with a preview of your post. If you are happy with how it looks, publishing is as easy as moving the .md file to the _publish-now” folder.

I by no means am an expert, so if you find problems with my walkthrough or don’t feel I’ve explained something enough, feel free to ping me on Twitter!

Previous post
OmniFocus: My Refined To-do Strategy Back in January I discussed my thoughts in re-evaluating my to-do and calendering strategies. While my basic principles have remained the same, I
Next post
Simplify for the Best I recently read about “the love metric” from Patrick Rhone: This year: Only hold onto things you love. Next year: Only hold onto things you not