NodeJS with Neo4J on Raspberry PI 3 working well and can be a good starting point to serve an AngularJS application. Then let us to show you how to do, our starting point will be to prepare our Raspberry PI 3 with the latest version of raspbian on our micro SD card.

raspberry-pi-3

Pre-requisites

  • The last version of Raspbian for your raspberry PI 3 who can be downloaded here: https://www.raspberrypi.org/downloads/raspbian/
  • The Win32DiskManager software (you can download it from here) to put the .img file of Raspbian for your raspberry PI 3 on the micro SD card
  • A micros SD card (in our case we will be use a SanDisk Extreme micro SD HC I of 32GB)

sandisk-extreme-micro-sdhc-32gb-card

Install of Raspbian on the micro SD card

Put you micro SD card with adapter on the computer where you donwloaded Raspbian for your raspberry PI 3. Unzip the .zip file you downloaded from raspberry to retrieve the .img file, after this launch Win32DiskManager and go search the path of you .img file. When done select the device corresponding to your micro SD card and click  on “write” to send the .img of raspbian to the micro SD card.

 

installer-raspbian-1

When you have the message “Confirm overwrite” choose “Yes”

confirm-win32-disk-imager

Your micro SD card is now ready and you can put it into your raspberry PI 3 for the next step

The first boot of your raspberry PI 3

The first thing you need to do is to expand the filesystem to use the entire space of your micro SD card. To do this go in terminal and put

 sudo raspi-config

raspi-config

1/ Expand the filesystem to use the entire space of the micro SD card

Select the option number 1 in the list to do this. When done we can proceed of the rest of the setup

2/ Change the user password

Make your raspberry PI 3 more secure and change the user password

3/ Change the boot options

Make the access more secure with asking user credential, better than autologin

9/ Advanced Options

Change the Hostname and activate SSH for remote access to the raspberry PI 3

When you finished restart the raspberry

Install the last version of NodeJS (version 4.5 in our case)

Install NodeJS on the Raspberry PI 3 is not something complicate and is very similar to a normal installation. You can proceed directly on the raspberry PI 3 or via a ssh connection

First you need to retrieve the latest version on NodeJS in https://nodejs.org/dist/latest-v4.x/ for linux-armv61.tar.gz at this time it’s the node-v4.5.0-linux-armv61.tar.gz then use the command:

wget https://nodejs.org/dist/latest-v4.x/node-v4.5.0-linux-armv6l.tar.gz
tar -xvf node-v4.5.0-linux-armv6l.tar.gz
cd node-v4.5.0-linux-armv6l

After you just need to copy the content of the directory in /usr/local

 sudo cp -R * /usr/local/

Your nodeJS is ready to use, you can control the version with node -v and npm -v

Install the last version of Neo4J (version 3 in our case)

Same than NodeJS install Neo4J on a raspeberry PI is something very easy. The last version of raspbian have already the oracle-java8-jdk installed then not need to do.

First you need to add the Neo4J repository

wget -O - https://debian.neo4j.org/neotechnology.gpg.key | sudo apt-key add -
echo 'deb http://debian.neo4j.org/repo stable/' >/tmp/neo4j.list
sudo mv /tmp/neo4j.list /etc/apt/sources.list.d
sudo apt-get update

Then you can make the installation of Neo4J

sudo apt-get install neo4j

When finished make a verification of the status of the service

sudo service neo4j status

neo4j-service

Fix the WARNING: Max 1024 open files allowed, minimum of 40000 recommended

To fix this warning at starting of the neo4j service you need to edit the file /etc/security/limits.conf and add the content

    root    soft    nofile  40000
    root    hard    nofile  40000
    neo4j   soft    nofile  40000
    neo4j   hard    nofile  40000

And check in the file /etc/pam.d/su if the line is uncommented

    session    required   pam_limits.so

The Neo4J config

Edit the file /etc/neo4j/neo4j.conf to make modification if:

  • You want to use a specific path or name for your graph database
# The name of the database to mount
dbms.active_database=mydatabasegraphname.db

# Paths of directories in the installation.
dbms.directories.data=/mypathtomydatabase
  • Authorize the upgrade of an existing database (need to uncomment)
# Enable this to be able to upgrade a store from an older version.
dbms.allow_format_migration=true
  • Authorize non-local HTTP connections or specific connexion
# To accept non-local HTTP connections, uncomment this line
dbms.connector.http.address=0.0.0.0:7474

You’re now ready to serve your AngularJS application, enjoy