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.
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.
Ideally I will make a script to get most of this going soon … but in the meantime, you are treated to a meta-blog.
Step 0, clone the repositories¶
I need to generate some SSH keys and register them to BitBucket and GitHub. So, one for BitBucket:
mjl@tesla:~> ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/mjl/.ssh/id_rsa): /home/mjl/keys/bitbucket Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/mjl/keys/bitbucket-temp. Your public key has been saved in /home/mjl/keys/bitbucket-temp.pub. The key fingerprint is: eb:db:95:03:c9:d9:de:22:74:cf:5f:bf:b8:c2:1d:c3 [MD5] email@example.com The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | . + | | S * + | | o + E | | . o B * .| | . . = +..o| | o.. .o..+| +--[MD5]----------+ mjl@tesla:~>
And also another for GitHub:
mjl@tesla:~> ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/mjl/.ssh/id_rsa): /home/mjl/keys/github Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/mjl/keys/github-temp. Your public key has been saved in /home/mjl/keys/github-temp.pub. The key fingerprint is: c7:1f:a1:95:53:31:65:e9:3f:9b:82:bb:1a:f9:6d:ba [MD5] firstname.lastname@example.org The key's randomart image is: +--[ RSA 2048]----+ | +o+| | o + | | = . | | . o o . | | S + . .| | ... . ..| | o o +| | o..o o | | ..E*.. | +--[MD5]----------+ mjl@tesla:~>
Then add them to my ssh-agent:
mjl@tesla:~> ssh-add keys/bitbucket Enter passphrase for keys/bitbucket: Identity added: keys/bitbucket (keys/bitbucket) mjl@tesla:~> ssh-add keys/github Enter passphrase for keys/github: Identity added: keys/github (keys/github) mjl@tesla:~>
(and also register them at each web site using the profile settings)
Now I can clone the repositories:
Clone my BitBucket Mercurial repository for the blog markup
mjl@tesla:~> mkdir blogs; cd blogs mjl@tesla:~/blogs> hg clone ssh://email@example.com/sinewalker/blog milosophical.me
and clone my GitHub Git repository for deploying at GitHub Pages
mjl@tesla:~/blogs> cd milosophical.me mjl@tesla:~/blogs/milosophical.me> git clone firstname.lastname@example.org:sinewalker/sinewalker.github.io.git
Step 1: Build environment¶
Nikola is built with Python, so it is best to use a VirtualEnv and install all the libraries. I'm using the VirtualEnv Wrapper scripts. 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:
sudo zypper install python-virtualenv-wrapper python-devel nodejs libxml-devel libxml2-devel libxslt-devel
Step 2: Install Nikola¶
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):
mjl@tesla:~> source /usr/bin/virtualenvwrapper-2.7.sh mjl@tesla:~> mkvirtualenv -p /usr/bin/python2.7 blog Running virtualenv with interpreter /usr/bin/python2.7 New python executable in test/bin/python2.7 Also creating executable in blog/bin/python Installing setuptools, pip...done. (blog)mjl@tesla:~>
Now switch to our blog working copy and install Nikola using
pip and the
requirements.txt I have saved:
(blog)mjl@tesla:~> cd blogs/milosophical.me (blog)mjl@tesla:~/blogs/milosophical.me> pip install -r notes/requirements.txt
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).
Step 3: Test Nikola¶
You should be able to run
nikola commands now and see that things are working.
Make a test post:
(blog)mjl@tesla:~/blogs/milosophical.me> nikola new_post -f markdown Creating New Post ----------------- Title: Test Post Scanning posts..........done! [2015-06-08T12:29:03Z] INFO: new_post: Your post's text is at: posts/test-post.md (blog)mjl@tesla:~/blogs/milosophical.me>
Serve the site:
(blog)mjl@tesla:~/blogs/milosophical.me> nikola serve [2015-06-08T12:29:27Z] INFO: serve: Serving HTTP on 0.0.0.0 port 8000...
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 …