Introduction

Hello and welcome to my blog. I’m intending to write in it when I have time. Hopefully by the end, it will resemble something interesting.

Today, the 1st of November, I set up the blog. It’s a little rudementary but the goal was to get it done in one evening. As you can see from the footer, it’s powered by Hexo with the Frame theme.

I found it relatively easy to set up, with my one hiccup being setting up a systemd service for it, so I can forget about how to actually run it.

The reason for this hiccup is of course relative vs. absolute paths, and folks tendancy to assume everyone else’s Node install looks exactly like theirs.

I’m not sure how normal this is to do, I am running this on a very non standard bitnami nginx image, that has caused 20 more headaches than it has solved, but here is how I achieved a working systemd service configuration.

systemctl and Hexo

This seems backward, but it’s the shortest path I can think of to get this working for you.

First, you’ll want to copy paste this into a .services file. On my installation of linux, I put it into /lib/systemd/system/blog.service, your installation location may be different.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[Unit]
Description=<your name>'s Blog
Documentation=Fucking none.
After=network.target

[Service]
Type=simple
User=<username your website will run under>
WorkingDirectory=<absolute path to the blog folder you setup with hexo>
ExecStart=<absolute path to hexo binary> server
Restart=always

[Install]
WantedBy=multi-user.target

To find the absolute path to your hexo binary, simply run:

1
which hexo

It’s advisable to run your website under a separate user with reduced permissions on your sever, this reduces your threat surface. If you don’t care, or believe you’re too small a target, don’t bother, I’m not your parent.

After you’ve filled in the <stuff> with your own details, you’re almost ready to rock.

Next, we’ll run it, it will probably fail, but then we get to know our computer better.

1
systemctl start blog.service

You can see if it’s up or down now using

1
systemctl status blog.service

If it’s up, congrats, you don’t need to do anything else.

If it failed, there should be an error message telling you it couldn’t find the node binary in /lib/bin/ or something similar. If you can’t find an error telling you what failed, try tail -n 100 /var/log/syslog. Regardless of where the error appears, no problem, we’ll symlink it.

If you, like me, can never remember which way around the target and link name go, I suggest quickly running man ln, then praying you’re not on alpine or busybox.

1
ln <absolute path to Node binary> <path it compained about not finding it in>

And you should be golden!

If you have encountered another error, I don’t have any specific advise, but my general advice would be: Check everything is where you, and the program, thinks it is. Likely there’s something that’s out of place.

That’s it for today, talk tomorrow.

Meghan