Install the Node.js virtual machine in VirtualBox

Zápisník experimentátora

Hierarchy: Node.js

This article describes how to install a​ Bitnami virtual machine. Their ready-made virtual machines have the advantage that everything is ready and you do not have to install everything. You only need to modify pre-installed machine to your needs.

Installation

The virtual machine can be downloaded from the​ VirtualMachines hypertext. Several versions are available. You usually choose the latest one. At the time of writing the article, it was version 7.8.0. So slightly delays to the official top-level version of​  Node.js, where version 7.9.0 was already available. Bitnami requires creating a login name and password. Feel free to use your own e-mail, do not send you any superfluity. After downloading, you will get bitnami-nodejs-7.8.0-0-linux-ubuntu-14.04-x86_64.ova.

This is imported into the VirtualBox via File/Import Appliance. You select the location of the file on the disk and the dialog will give you additional settings. You must double-click the settings and then the option to change the parameter appears. After pressing the Import button, a new virtual machine will be created. Start the virtual machine with the Start button.

Sign in with the following parameters:

  • ubuntu login: bitnami
  • password: bitnami

The program will prompt you to change the password, so set your own. If you have mistaken it, use the passwd command again and set your own password. Take care of NumLock in Windows. This virtual machine always switches it to me and I have to turn on NumLock again. Use the exit command to return to the login menu and try a new login password.

Setting

For sure, make sure you have the network setup for this virtual machine as Attached to: Bridget Adapter. This network setting allows the virtual machine to connect to the Internet or to your computer, and also lets you connect to the virtual machine from your computer.

SSH

To get you more comfortable, you need SSH access. By default, SSH in the virtual machine is off. First, make sure that the SSH port is enabled (22).

sudo iptables -L | grep tcp

If it is not, enable it

sudo ufw allow 22/tcp

Now we need to turn on the SSH server.

sudo mv /etc/init/ssh.conf.back /etc/init/ssh.conf
sudo start ssh

You can find the IP address of your virtual machine when you log in to the virtual server or with the ifconfig command. Run the program putty and enter the IP address and port 22. Putty will protest that it does not have a virtual machine imprint, but let it be quiet and do not bother to do so. If you see a window with a login name and password, you have succeeded and you can log in as follows. Enrollment via putty has the advantage of having a better history of orders entered. See what I'm saying when you type a command that lists multiple rows. In the regular VirtualBox window, it quickly takes you away. Using a putty, you can scroll with the mouse over the entire text.

MC

As people bred on Windows, you will definitely want to browse the contents of the disc and you will be able to use the mc program here. Install it and run it.

sudo apt-get install mc
mc

Checking the installed version of Node.js

Enter the following commands and see what version of Node.js is and what is installed through npm, which is the package manager for Node.js. The following command lists the contents of the global repository in level 0, which means that you only see root packages.

node -v
npm list -g --depth=0

Checking Redis cache

This is an activity that you do not have to do but you may want to do it. According to my experience, the bug has been made in the preinstalled virtual machine, and Redis needs to be configured. First, with the grep command, find out if the Redis port is turned on and when it is not, edit the configuration and restart the server. It is advisable to execute orders in such order.

grep port ~/stack/redis/etc/redis.conf
sudo /opt/bitnami/ctlscript.sh stop redis
sudo nano ~/stack/redis/etc/redis.conf
sudo /opt/bitnami/ctlscript.sh start redis

Check that the Redis process works and is on the right port.

sudo ps aux | grep redis

Final launch of the examples

You can try my examples.

mkdir projects
cd projects
git clone https://github.com/roboulbricht/node.js-tests
cd node.js-tests

And run the example

cd 00-hello-world
node hello.js

Conclusion

Now you have a virtual server ready for work and you can match it to your Node.js creations without having anything installed on your main computer. Nothing prevents you from installing Node.js there and testing examples locally.


02.09.2017


Menu