Connect with us

Website Tutorials

How to Install Node.js in WHM via EasyApache 4

Published

on

How to Install Node.js in WHM via EasyApache 4

Node.js is an environment that allows you to execute JavaScript on servers. Normally, JavaScript is run by browsers and comes with all the browser’s limitations, including running in a sandbox and not having access to system resources. But Node.js expands this functionality and allows programmers to leverage JavaScript to run on servers. This means that you can write JavaScript code that can perform complex processes like creating web servers, managing packages, and receiving network requests.

In this tutorial, I’ll explain how to install Node.js on WHM using EasyApache 4.

1. Log into WHM and Access EasyApache 4

Log into WHM using the root username and password that your service provider sent you during the setup process. Once logged into WHM, search for the “Software” tab on the left-hand side and expand the selection. Towards the bottom, you’ll see “EasyApache 4” as shown here:

EasyApache 4 in WHM
EasyApache 4 in WHM

2. Customize the Apache Profile

EasyApache 4 allows you to create and choose from a variety of profiles that you can implement all at once. You probably already have a profile set up for your server, so you just need to customize that. In the section called “Currently installed packages”, select “Customize” as shown here:

Customize EasyApache 4
Customize EasyApache 4

This will lead us to a screen where we can choose which packages we want to install using EasyApache.

In the next screen, we see all the packages that we can install under different subsections. For Node.js, click “Additional Packages” as shown here:

Additional Packages in EasyApache 4
Additional Packages in EasyApache 4

This can be a long list, so it’s best to use the search functionality on top to search for the package that you want. The exact name of the package can keep changing, so just search for “nodejs” and you should get the package that you’re looking for as shown here:

Select Node.js Package to Install
Select Node.js Package to Install

As shown above, the package that we’re interested in is called “nodejs16”, with an “Install” toggle button next to it. Turn this toggle to “on” and click “Next”. This, however, doesn’t mean that the package is immediately installed. The whole process involves re-configuring Apache with the new package – a step called “provisioning”.

The next screen will show you a breakdown of the new packages that are going to be installed. As you can see, nodejs16 is the only one on the list:

Advertisement
Review Node.js Installation
Review Node.js Installation

Scroll all the way down, and click “Provision” as shown here:

Provision EasyApache 4
Provision EasyApache 4

This will start the provisioning process. It can take some time, as compiling Apache with all the required packages isn’t a simple process. But eventually, it’ll complete and you’ll get a message like this:

EasyApache 4 Provisioning Complete
EasyApache 4 Provisioning Complete

3. (Optional) Reboot the Server

I personally prefer to reboot the server after changing the Apache configuration like this, though I suppose it’s not strictly necessary. To reboot the server from the command line, use the following command:sudo reboot

This will ask you for your sudo password, which you should enter.

4. Install the ea-utils tool on Linux

Once you’ve finished installing Node.js, you still need to finish up some installation processes before you can run the “node” command on Linux. To do this, SSH into your server and install the “ea-utils” tools. On Ubuntu, the command is:sudo apt install ea-utils

This will commence a long installation, and at the end of it, you can confirm that Node.js is installed on your server by typing the following command:node -v

This will give you the following output:

Node -v
Node -v

From here, you can start issuing commands to the Node.js runtime.

What Makes Node.js So Special

We’re all familiar with JavaScript – the language that powers so much of our browser applications. The problem is that while it works in the browser, developers still need to use another language to handle the back-and-forth communications between the browser and the server. In a traditional application like WordPress, JavaScript and PHP have clearly defined roles – one for the browser, and one for the server.

Advertisement

Even though we can use PHP script to generate JavaScript in WordPress to run on the browser, the two don’t interact directly. If communication between the two is necessary, it’s typically done via AJAX requests, which is a very sanitized form of communication.

Example: How Node.js Could Have Been Useful on WordPress

The best way to demonstrate what Node.js does is to imagine the role it could play in an environment like WordPress, which currently doesn’t integrate Node.js in any way.

Let’s say you wanted WordPress to serve as the platform for a collaborative document – like what we have in Google Docs. The goal is for several people to edit a document simultaneously. Naturally, WordPress is a terrible environment for a project like this done on scale. Every time a user makes a change to the document, it’ll have to send an AJAX request to the back-end, causing a “request-response” loop. The PHP server in the back-end would need to update the database and send the updated data to all connected users.

Other clients working on the same document, would need to constantly “poll” the server to check for changes. This introduces constant overhead and wasted resources as clients everywhere would be checking in on the server, even when there are no updates to be synchronized.

The resources and time spent making this work are unscalable, and even for a small project, it would require immense architecturing and coordination to make it happen. But if we wanted to implement the same thing with Node.js, it suddenly becomes much simpler. For one thing, you could use JavaScript for both the front and back end, reducing the problem of coordinating multiple languages.

Advertisement

Node.js Uses Websockets

Node.js uses a communication protocol known as WebSockets, which allows the client and the server to communicate with each other simultaneously, without needing for one to wait for the other to respond. This is known as “full-duplex” communication and is a crucial part of what makes Node.js so powerful.

In our document collaboration example, we could use Node.js to push updates to the server, and the server would then be able to use the WebSockets communication protocol to automatically push the updates to the clients without waiting for the clients to contact it first. This allows Node.js to be “event-driven”, meaning that there’s no need to schedule a request or a response. Updates can happen whenever they need to.

Hopefully, this example brings to light the stark differences between Node.js and older applications like WordPress.

Conclusion

It’s for these reasons, that massive, globally scaling applications like Netflix have chosen to use Node.js. Right now, most web hosts don’t offer Node.js hosting out of the box. That’s because legacy applications like WordPress are still so dominant, and the primary way we consume content on the Internet is still by visiting web pages. But when we really need to develop customer-facing applications that need to be updated in real time, then something like Node.js becomes a compelling option. I hope you found this short tutorial and explanation of Node.js useful!

Advertisement

Stephen Oduntan is the founder and CEO of SirsteveHQ, one of the fastest growing independent web hosts in Nigeria. Stephen has been working online since 2010 and has over a decade experience in Internet Entrepreneurship.

Continue Reading
Advertisement
Comments

Trending

Copyright © 2024 SirsteveHQ. All Rights Reserved.