About a week a go I bought myself a Synology. A very nice product with reasonable value for money. Especially if you consider the options you have if you are not scared to get your hands dirty. Agreed the graphical admin console is nice, but the linux options are even nicer. I wanted to have a cheap solution to host a node.js server at home. In the end I am glad I made the choice for this model.
In this blog post I will provided as much steps that I can remember and or wrote down while installing a node.js server on my Synology. This was not the easiest thing I have ever done. If I can help some others that want to get more out of their Synology my hours of work are worth it.
The Synology comes with an installed firmware. In my case I started with the 3.1 DSM software.
Tweaking you Synology starts with obtaining Terminal access. You can enable this in the configuration panel of DSM. By default you can access your synology using DiskStation.local with the admin or root account. For the things we are going to do I recommend using the root account. The password for the root account is the same as for the admin account. Just so you know. Go on check if you have access
# ssh root@DiskStation.local
The next step is to install ipkg, the package manager for you synology. There are multiple resources on the web that explain how to do this. Most of them point to this wiki page. It is important to take the right version of the bootstrap for your synology system. The variations in processors used are big, therefore you have to use the right software. The processor can be obtained using this page. You can also find out more about your system from the command line.
DiskStation> uname -a Linux DiskStation 220.127.116.11 #1605 Thu Mar 24 02:12:03 CST 2011 armv5tel GNU/Linux
For the DS211+ I needed the Marvel Kirkwood mv6282 ARM. The easiest way to get in onto your system is to use wget. Remember that tool, we will talk more about it.
I created a downloads folder in the home folder of root. Executing the script is very easy
Now we have ipkg installed. The best way to check if it works is to update and upgrade.
DiskStation> ipkg update Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/Packages.gz Inflating http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/Packages.gz Updated list of available packages in /opt/lib/ipkg/lists/cross Successfully terminated. DiskStation> ipkg upgrade Nothing to be done Successfully terminated.
If you just want to install software that is available via ipkg, this is it. In my case I want to install node.js. This is not available via ipkg, therefore we need to compile it ourselves. This is where the problem starts. So in the next section we will have a look what you need to compile stuff.
Compile from source
Compiling source code on linus needs compilers (gcc) and headers files. The header files contain information about the libraries that are required during compilation of code that makes use of these libraries. Ipkg has the option to install development libraries that are required to compile source. To bad the current version does not work out of the box. With the help of some resources on the web and a lot of experimentation I finally got a working system. This part is the most important part of getting your system ready to compile node.js.
Usually you would install optware-devel with ipkg. But we start off with some other libraries that will not work with optware-devel.
ipkg remove wget wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/wget-ssl_1.12-2_arm.ipk wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/openssl_0.9.8p-1_arm.ipk wget http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/unstable/libidn_1.19-1_arm.ipk ipkg install libidn_1.19-1_arm.ipk ipkg install openssl_0.9.8p-1_arm.ipk ipkg install wget-ssl_1.12-2_arm.ipk ipkg install openssl-dev
We are almost set, now I have a problem with my limited linux knowledge. I found some resources on the web and in the end I had to copy some resources around. So these steps might not be optimal, but they did work for me.
I took the first step from this post.
mkdir /opt/arm-none-linux-gnueabi/lib_disabled mv /opt/arm-none-linux-gnueabi/lib/libpthread* /opt/arm-none-linux-gnueabi/lib_disabled cp /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/ cd /opt/arm-none-linux-gnueabi/lib/ ln -s libpthread.so.0 libpthread.so ln -s libpthread.so.0 libpthread-2.5.so
The final copying you need to do actually only appeared to me when running node.js. Therefore I am not completely sure if this is right, but again it works for me.
cp /opt/lib/libssl.so.0.9.8 /usr/lib cp /opt/lib/libcrypto.so.0.9.8 /usr/lib
If I remember correct, now is the time to start downloading node.js and start compiling.
Before we start compiling we need to have some source. This page describes what you need to do:
I downloaded node in the /root folder, called ./configure and put the results in /opt/node. Before you can do that you need to install git first. This is easily done using ipkg. Now the steps to perform:
ipkg install git cd /root git clone https://github.com/joyent/node.git cd node ./configure --prefix=/opt/node make make install
Hope it all goes as aspected and no errors arise. Beware the make step can take a long time (15-30 minutes or something). The next step is to add node.js to your path. In the root folder you can find the .profile file. In here you will find a PATH variable. Change it to include the folder /opt/node/bin. Something like this
That is the end of the journey. Now you can do your node things like install npm, express, jade, sass, socket.io, etc. If you have an application running you can execute it from the shell. The problem is that it does not keep running when you logout. There are multiple mechanisms to keep the process running. I found one that is actually itself a node.js application. It seems to do the trick for me.
That is it, node.js running on your synology. if you want more information about what I am running on my synology, check the sources on Github or check my previous blog post.