{ "metadata": { "name": "", "signature": "sha256:9b155585ebcb66a8ae75c106b92038c3e3b43b3ca953479f630e9ee6776126ec" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Tonight I thought that I'd sit down at my home server, *Tesla*, and do a bit of blogging. This server's recently been rebuilt after a bad run-in with a hard-drive problem and I had not got around to putting my blog onto it. Instead I was blogging with work's laptop.\n", "\n", "After spending an hour cloning and installing my blog repositories and the necessary software through trial-and-error, I thought it best to write down what is necessary to bootstrap my blogging environment, and save myself some trouble in the future.\n", "\n", "Ideally I will make a script to get most of this going soon … but in the meantime, you are treated to a meta-blog." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 0, clone the repositories\n", "----\n", "\n", "I need to generate some SSH keys and register them to BitBucket and GitHub. So, one for BitBucket:\n", "\n", "```\n", "mjl@tesla:~> ssh-keygen \n", "Generating public/private rsa key pair.\n", "Enter file in which to save the key (/home/mjl/.ssh/id_rsa): /home/mjl/keys/bitbucket\n", "Enter passphrase (empty for no passphrase): \n", "Enter same passphrase again: \n", "Your identification has been saved in /home/mjl/keys/bitbucket-temp.\n", "Your public key has been saved in /home/mjl/keys/bitbucket-temp.pub.\n", "The key fingerprint is:\n", "eb:db:95:03:c9:d9:de:22:74:cf:5f:bf:b8:c2:1d:c3 [MD5] mjl@tesla.locknet\n", "The key's randomart image is:\n", "+--[ RSA 2048]----+\n", "| |\n", "| |\n", "| |\n", "| . + |\n", "| S * + |\n", "| o + E |\n", "| . o B * .|\n", "| . . = +..o| \n", "| o.. .o..+| \n", "+--[MD5]----------+ \n", "mjl@tesla:~>\n", "```\n", "\n", "And also another for GitHub:\n", "\n", "```\n", "mjl@tesla:~> ssh-keygen \n", "Generating public/private rsa key pair.\n", "Enter file in which to save the key (/home/mjl/.ssh/id_rsa): /home/mjl/keys/github\n", "Enter passphrase (empty for no passphrase): \n", "Enter same passphrase again: \n", "Your identification has been saved in /home/mjl/keys/github-temp.\n", "Your public key has been saved in /home/mjl/keys/github-temp.pub.\n", "The key fingerprint is:\n", "c7:1f:a1:95:53:31:65:e9:3f:9b:82:bb:1a:f9:6d:ba [MD5] mjl@tesla.locknet\n", "The key's randomart image is:\n", "+--[ RSA 2048]----+\n", "| +o+|\n", "| o + |\n", "| = . |\n", "| . o o . |\n", "| S + . .|\n", "| ... . ..|\n", "| o o +|\n", "| o..o o |\n", "| ..E*.. |\n", "+--[MD5]----------+\n", "mjl@tesla:~>\n", "```\n", "\n", "Then add them to my ssh-agent:\n", "\n", "```\n", "mjl@tesla:~> ssh-add keys/bitbucket\n", "Enter passphrase for keys/bitbucket: \n", "Identity added: keys/bitbucket (keys/bitbucket)\n", "mjl@tesla:~> ssh-add keys/github\n", "Enter passphrase for keys/github: \n", "Identity added: keys/github (keys/github)\n", "mjl@tesla:~> \n", "```\n", "\n", "(and also register them at each web site using the profile settings)\n", "\n", "Now I can clone the repositories:\n", "\n", " * Clone my BitBucket Mercurial repository for the blog markup\n", " \n", " ```\n", " mjl@tesla:~> mkdir blogs; cd blogs\n", " mjl@tesla:~/blogs> hg clone ssh://hg@bitbucket.org/sinewalker/blog milosophical.me\n", " ```\n", "\n", " * and clone my GitHub Git repository for deploying at GitHub Pages\n", " \n", " ```\n", " mjl@tesla:~/blogs> cd milosophical.me\n", " mjl@tesla:~/blogs/milosophical.me> git clone git@github.com:sinewalker/sinewalker.github.io.git\n", " ```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 1: Build environment\n", "----\n", "\n", "[Nikola](https://getnikola.com/) is built with Python, so it is best to use a [VirtualEnv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) and install all the libraries. I'm using the [VirtualEnv Wrapper scripts](http://virtualenvwrapper.readthedocs.org/en/latest/index.html). Nikola's dependencies also require a few things to be installed at the operating system layer. So before starting with my virtual environment, I install the base development tools *outside* of Python, but using the operating system's package management:\n", "\n", "```\n", "sudo zypper install python-virtualenv-wrapper python-devel nodejs libxml-devel libxml2-devel libxslt-devel\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 2: Install Nikola\n", "----\n", "\n", "Once the build environment is all installed, we can begin. We'll make a new virtual environment for our blog, making sure to use Python 2.7 (Nikola supports Python 3, but my blog doesn't, yet):\n", "\n", "```\n", "mjl@tesla:~> source /usr/bin/virtualenvwrapper-2.7.sh\n", "mjl@tesla:~> mkvirtualenv -p /usr/bin/python2.7 blog\n", "Running virtualenv with interpreter /usr/bin/python2.7\n", "New python executable in test/bin/python2.7\n", "Also creating executable in blog/bin/python\n", "Installing setuptools, pip...done.\n", "(blog)mjl@tesla:~>\n", "```\n", "\n", "Now switch to our blog working copy and install Nikola using `pip` and the `requirements.txt` I have saved:\n", "\n", "```\n", "(blog)mjl@tesla:~> cd blogs/milosophical.me\n", "(blog)mjl@tesla:~/blogs/milosophical.me> pip install -r notes/requirements.txt\n", "```\n", "\n", "This will take a while. You can repeat the `pip` command until it succeeds, installing anything I have left out (base development packages, for instance — like C compilers and libraries — although I *think* that these should be installed by `python-devel`'s dependencies if you haven't already installed them)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Step 3: Test Nikola\n", "----\n", "\n", "You should be able to run `nikola` commands now and see that things are working.\n", "\n", "Make a test post:\n", "\n", "```\n", "(blog)mjl@tesla:~/blogs/milosophical.me> nikola new_post -f markdown\n", "Creating New Post\n", "-----------------\n", "\n", "Title: Test Post\n", "Scanning posts..........done!\n", "[2015-06-08T12:29:03Z] INFO: new_post: Your post's text is at: posts/test-post.md\n", "(blog)mjl@tesla:~/blogs/milosophical.me>\n", "```\n", "\n", "Serve the site:\n", "\n", "```\n", "(blog)mjl@tesla:~/blogs/milosophical.me> nikola serve\n", "[2015-06-08T12:29:27Z] INFO: serve: Serving HTTP on 0.0.0.0 port 8000...\n", "```\n", "\n", "Nice. Now I can blog (i.e. this post). Remember when done with a VirtualEnv environment, you leave it by typing `deactivate`. Just think of ***Cars 2*** …" ] } ], "metadata": {} } ] }