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.


Terminal access

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

ipkg

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 2.6.32.12 #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.

wget http://wizjos.endofinternet.net/synology/archief/syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh

I created a downloads folder in the home folder of root. Executing the script is very easy

sh syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh

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.

Compiling node.js

Before we start compiling we need to have some source. This page describes what you need to do:

https://github.com/joyent/node/wiki/Installation

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

PATH="/opt/node/bin:$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/usr/local/sbin"

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.

https://github.com/indexzero/forever

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.

http://www.gridshore.nl/2011/03/16/first-steps-with-node-js/

https://github.com/jettro/nodejstryout

Tagged on:             

13 thoughts on “Installing Node.js on my new Synology

  • July 25, 2012 at 8:24 am
    Permalink

    Hi,
    tried to follow your article but i always fail on make…
    Seems to be the dependancy wtih openssl that fail.
    Don’t know why.

    CC(target) /root/node/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.o
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c: In function ‘bn_mul_add_words’:
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:117: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:117: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:117: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:118: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:118: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:118: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:119: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:119: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:119: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:120: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:120: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:120: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:125: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:125: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:125: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:126: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:126: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:126: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:127: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:127: error: impossible constraint in ‘asm’
    ../deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.c:127: error: impossible constraint in ‘asm’
    make[1]: *** [/root/node/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/bn/asm/x86_64-gcc.o] Error 1
    make[1]: Leaving directory `/root/node/out’
    make: *** [node] Error 2

    Reply
    • August 3, 2012 at 11:48 pm
      Permalink

      Sorry, I am afraid I cannot help you. All my memory is in this blogpost. To be honest, I do not use the system like this anymore. So I cannot have a look at the config any longer. Could the problem be in 64 bit and not installing the 64 bit ssl package?

      Reply
  • December 29, 2011 at 4:55 pm
    Permalink

    Hey,

    I’m currently looking for a “low cost/good compromises” solution to get a dlna and a web server at the same time.
    Your post is very interesting because one of my needs would be to run node.

    Now i know it’s possible, but what about performances ? Did you try to do a kind of benchmark or stress test ?
    For example, how many time (in ms) does it take to serve a simple web page ?

    My 2nd choice is much more expensive : the mac mini..

    Thanks

    Reply
    • January 6, 2012 at 6:32 pm
      Permalink

      No I did not do performance tests. But I think it is ok as long as you do not want to do a lot of other things at the same time.

      Reply
  • October 31, 2011 at 3:47 pm
    Permalink

    When i try to run “./configure –prefix=/opt/node” i get: “env: python: No such file or directory”

    Reply
  • September 11, 2011 at 4:21 pm
    Permalink

    Thanks for posting this, it has helps an awful lot. I’m installing a DS209 with the ARM 6281. I’m building 0.5.6 using DSM 3.2. Running configure seems ok:


    DiskStation> ./configure --prefix=/opt/node --openssl-libpath=/opt/lib
    Checking for program g++ or c++ : /opt/bin/g++
    Checking for program cpp : /opt/bin/cpp
    Checking for program ar : /opt/bin/ar
    Checking for program ranlib : /opt/bin/ranlib
    Checking for g++ : ok
    Checking for program gcc or cc : /opt/bin/gcc
    Checking for program ar : /opt/bin/ar
    Checking for program ranlib : /opt/bin/ranlib
    Checking for gcc : ok
    Checking for library dl : yes
    Checking for function SSL_library_init : yes
    Checking for header openssl/crypto.h : yes
    Checking for library util : yes
    Checking for library rt : not found
    Checking for fdatasync(2) with c++ : no
    'configure' finished successfully (3.818s)

    When I run make, things seem fine initially. However, GCC seems to be crapping out randomly. I get segmentation faults at various points in the complication process. For example:


    /opt/bin/g++ -o obj/release/messages.o -c -fno-rtti -fno-exceptions -Wall -W -Wno-unused-parameter -Wnon-virtual-dtor -Wno-abi -pedantic -mfloat-abi=softfp -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -ansi -DCAN_USE_VFP_INSTRUCTIONS -DUSE_EABI_HARDFLOAT=0 -DV8_TARGET_ARCH_ARM -DENABLE_DEBUGGER_SUPPORT -I/volume1/homes/admin/GitHub/node/deps/v8/src /volume1/homes/admin/GitHub/node/deps/v8/src/messages.cc
    In file included from /volume1/homes/admin/GitHub/node/deps/v8/src/elements.h:31,
    from /volume1/homes/admin/GitHub/node/deps/v8/src/objects-inl.h:38,
    from /volume1/homes/admin/GitHub/node/deps/v8/src/v8.h:60,
    from /volume1/homes/admin/GitHub/node/deps/v8/src/messages.cc:29:
    /volume1/homes/admin/GitHub/node/deps/v8/src/objects.h:5301: internal compiler error: Segmentation fault
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See for instructions.
    scons: *** [obj/release/messages.o] Error 1
    scons: building terminated because of errors.
    Waf: Leaving directory `/volume1/homes/admin/GitHub/node/out'
    Build failed: -> task failed (err #2):
    {task: libv8.a SConstruct -> libv8.a}
    make: *** [program] Error 1

    It never fails in the same spot twice, which leads me to believe it’s GCC and not Node.js. Anyone else experience something similar?

    Ryan-

    Reply
  • September 3, 2011 at 12:30 am
    Permalink

    Thanks for the tips! I thought I’d add a few notes on my experience building Node on my DS1511+, which isn’t based on the ARM CPU architecture the rest of your DiskStations are.

    First, I was careful to grab i686 packages instead of ARM:

    wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/libidn_1.21-1_i686.ipk
    wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/openssl_0.9.8p-1_i686.ipk
    wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/wget-ssl_1.12-2_i686.ipk

    (Aside: I also stuck all source code in a location outside of /root, since jettro mentioned DSM updates nuke it.)

    Second, I installed Python 2.7 and openssl-dev, as Node requires Python ≥2.6 and the libssl headers:

    ipkg install python27 openssl-dev
    cd /opt/bin
    ln -s python2.7 python

    I required Node 0.4.11 instead of bleeding edge, so after cloning the repository, I checked out the v0.4.11 tag: git checkout v0.4.11.

    Also, I turned Miro’s deps/libeio/wscript edit into a proper patch, if anyone’s interested.

    Finally, make failed with a regular ./configure --prefix=/usr/local/node while trying to compile mksnapshot.o, complaining about undefined reference to `__sync_fetch_and_add_4'. I think this has to do with gcc’s target architecture, but I couldn’t get -march=i686 or anything through to gcc, via CFLAGS or otherwise.

    I noticed that waf has a --without-snapshot option (see ./configure --help), which seemed to conveniently apply to my error. Using ./configure --prefix=/usr/local/node --without-snapshot, I can make without error. Running make test results in four failed tests out of 217, all of which seem to be child process-related. Some cautious poking around with a real Node app seems to be okay, so hopefully things will work out.

    Again, thanks for this post and the comments below! They were very helpful.

    Reply
  • July 3, 2011 at 9:33 am
    Permalink

    Beware, upgrading your dsm seems to clean the /root folder. Which is strange if you ask me. I had to do some of the steps again to make it work after the upgrade.

    Reply
  • April 22, 2011 at 4:35 pm
    Permalink

    Hi, I had no problems following your tutorial, saved me a great deal of time. However, I ran into a few issues. I have a Synology DS211+.

    #1 – I needed to run “ipkg install optware-devel” before I went to the “Compile from source” step

    #2 – When I ran “./configure –prefix=/opt/node”, the configure step was failing at checking for “pthread_atfork” and I found the solution – you need to edit /root/node/deps/libeio/wscript on line 13 (right after “conf.check(lib=’pthread’, uselib_store=’PTHREAD’)” )
    with “conf.env.append_value(‘LINKFLAGS’, ‘/opt/lib/libpthread_nonshared.a’)” (without quotes)

    After that, I ran “make” (took 37 minutes) and “make install”, then edited the PATH variables in /root/.profile

    You will then need to restart .profile in the root by doing “. /root/.profile” (without quotes) and it all worked!

    So thanks, hope this also helps someone.

    Reply
    • April 22, 2011 at 6:32 pm
      Permalink

      I cannot remember I had to do that, but I did a lot to get it working. Tried to reproduce the steps. Could well be I missed this one.

      Thanks for sharing

      Reply
    • May 27, 2011 at 3:06 am
      Permalink

      For my DS210j, I had to do both of those steps.
      I also, had to install python “ipkg install python”.

      The guide and the comments were invaluable. I couldn’t have installed it without it.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>