Getting Ghost to work on a QNAP NAS
Somehow, and I don't really remember how, I heard about the micro-blogging platform Ghost. I suppose I imagined that such a product might provide hosting and such-like for free. So I signed up to find out when it would be available. Sometime later I got an e-mail back from the team telling me the source code was ready.
Ahah! So what is being produced is a platform that you can integrate. Excellent ... I've got a QNAP TS-410 NAS running my other web-sites. This shouldn't be too difficult to get working (I thought to myself).
First up : node.js
The underlying platform for Ghost is the node.js
platform. So we need to get that working. It transpires that this is a pretty big stumbling block. First off, the QNAP app manager suggests that you could download and install node.js 0.8.22-2
. However, Ghost requires 0.10.*
and the 0.8.22-2
install also has a broken npm
manager.
So we are going to start from scratch, and actually get the NAS itself to recompile the whole of node.js
. Off to download v0.10.26
, untar and follow the instructions from various places on the web. Oh, and really make sure you have python installed as node.js relies on this for the build system.
export LINK=G++
make install
Sometime (several hours) later you will hit the following
undefined reference to '__sync_val_compare_and_swap_4'
This happens because the NAS has a fairly old gcc (4.2.3) and node.js needs a newer version. Fortunately others have hit this issue as well and there is a known way around it. Time to down load the source code for gcc 4.6.3
and compile the atomics into a library. I followed the advice above and simply changed the generated makefile, however I'm sure that there is a more elegant way to do this which modifies the source gyp code to achieve the same.
Next npm
has issues
OK, it's not too bad, but by default npm puts all its cache files into the /root
directory. And on a QNAP device there isn't much space there. So we need to configure npm to put it cache elsewhere (on the large NAS drives).
Getting Ghost working
Next up download a current version of ghost (0.4.2
) and set the install procedure going
npm install --production
The ghost docs point out that if you don't install --production
you get a load of stuff extra that you don't care about.
Hopefully, this should just work. But actually it took a bit of fiddling. Remember to have export LINK=g++
before kicking off the install since some of the packages might well need to build (in fact make sure that make
is on your path as well).
Time to try ghost
Having built and installed it you should be ready to try launching it using
npm start
This worked but I ran into the very, very slow implementation of bcryptjs
which means that login and user definition can take minutes. Others have seen this issue and come up with a work around. Once again make sure that you have LINK
exported correctly, and flock
installed (which is part of the util-linux
package)
ipkg install util-linux
Getting an external URL
Next up we are going to configure the Qthttpd
daemon to forward everything from a particular virtual host to the running ghost node. This requires the following in the apache config files
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ServerName blog.bedewell.com
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
ProxyPass /jos http://nas:2368/jos
ProxyPassReverse /jos http://nas:2368/jos
DocumentRoot "/share/Qweb/blog"
</VirtualHost>
With this, and telling the production blog that it is located at http://blog.bedewell.com/jos everything seems to work!