DevOps Part II

We are on our first step to become a DevOps expert. We will begin setting up a Linux Server (NodeJS) on a Virtual Machine. I recommend VirtualBox, it is open source and very easy to set up.

Preparing VirtualBox for running Ubuntu

Launch VirtualBox and select «New», the next prompt will appear. Make sure you select Linux and Ubuntu (32|64-bit) version.

Set the RAM

Select the Hard Drive Type

Your VM is almost ready, when you boot it from the first time, it prompts you to select the bootable file, make sure you select the *.iso file you downloaded from the Ubuntu webpage.

Follow the instructions prompted by the OS like creating an Username and Password, when it finished, we’re going to install the required packages for running Node.

Installing NodeJS & Git

First we need the curl package, open the Terminal app and type

sudo apt-get install curl

Next step is to download Node source, type the following command

curl -sL | sudo -E bash -

Once finished, let’s install NodeJS by running the next command

sudo apt-get install -y nodejs

Finally, verify that node and npm are correctly installed by checking the version of each one

node -v
npm -v

Our next step is to install git, so we run the next command

sudo apt-get install git

And like node and npm, let’s verify the installation by checking the version

git --version

Now let’s create a repository for serving a simple webpage using node and express. In a new folder run npm init, and fill the prompted options. This will let us install node packages using npm. Install express by running npm install express. Let’s write some HTML and JavaScript.


In the package.json file, add a new script for running our development server.

"scripts": {    
"start": "node src/index.js"

Run the script typing npm run start and open the browser in http://localhost:8080, you should see the following

It works!

Remember to add git to the project.

Now, we’re going to write a small cron job in our Virtual Machine, type the following

crontab -e

Select your desired terminal editor and you’ll be able to edit or add cron jobs

At the end of the file we will write the cronjob, add something simple like this

* * * * * echo 'Hello Cron!' > $HOME/cron.txt

This task will be running every minute and overwrite the file with ‘Hello Cron!’, close the file and save it. Next go to your home directory in one minute and see that the file is created

Amazing! We wrote our first cronjob in Linux. This is the part II of a series of five posts

Anuncio publicitario

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s