In an earlier tutorial, I’d written about how to install Node.js on EasyApache. However, this doesn’t mean that it’s easy for users to get started with creating a Node.js application.
If you have a shared hosting VPS, and you want to offer Node.js to your clients, then you need a much more streamlined way to allow them to use Node.js. That’s where the cPanel Node.js Selector comes in.
In this tutorial, I’ll show you how to use the command line on your server to install all the components of the cPanel Node.js plugin, and then enable it so that your users can start creating their own Node.js applications using the GUI.
Prerequisites
To install the Node.js Selector in cPanel, you need to have the following:
- Root access to your server
- A WHM account with root access
- A CloudLinux server
The first two are self-explanatory. The third requirement might trip you up if you’re unaware of what CloudLinux is.
What is CloudLinux and How Do You Know If You Have It?
CloudLinux is a Linux distribution based on CentOS, which is in turn, based on RHEL. The focus of CloudLinux is multi-tenancy – meaning shared hosting. It’s built from the ground up to accommodate account isolation and comes with a feature known as LVE – Lightweight Virtual Environment. This LVE ensures that a surge in resources from one account doesn’t impact the performance of other accounts on the server.
File System Isolation
CloudLinux also uses a filesystem called CageFS – a virtual file system ensuring that users in a shared hosting environment can never physically access the files and folders of others on the server. This goes beyond mere file-level permissions. CageFS elevates account separation on CloudLinux to such a degree that obtaining access to another user’s information is simply impossible.
Faster PHP With Mod_LSAPI
With so many users running WordPress, CloudLinux claims that its Mod_LSAPI system for delivering PHP webpages is faster than traditional methods like FastGI and mod_php. With all these features, CloudLinux is now a popular choice for a Linux OS if your intention is to run it as a shared hosting server.
How to Know if You’re Running CloudLinux
The Node.js Selector requires CloudLinux, so it’s essential for you to know whether or not you’re running this OS. To do this, log into WHM as root, and access the shell by typing “ssh” into the search box on the top-right hand corner like this:
In the tools drop-down box, click “Terminal” as shown above. This will open a terminal window within WHM, from which you can issue commands to check whether or not you’re running CloudLinux.
To check this, type:
cat /etc/redhat-release
This will print the version of Red Hat that you’re running. Since CloudLinux is based on CentOS, which in turn is based on Red Hat’s RHEL, you should get an output like this if you’re running CloudLinux:
As you can see, we’re indeed running CloudLinux and so we have all the conditions for installing the Node.js Selector app on cPanel.
Installing the Node.js Selector Pre-Requisites
Even though CloudLinux supports the Node.js selector natively, it doesn’t appear on our users’ cPanel dashboard on its own. In fact, it doesn’t show up in WHM either. We first need to install the following packages on CloudLinux:
- The group package alt-nodejs
- lvemanager
- lve-utils
- ea-apache24-alt_mod_passenger
- cagefs
The alt-nodejs group package is part of CloudLinux’s “Software Collections” – or SCL. It contains all the alternative Node.js versions, which is important because the Node.js selector allows us to target specific Node.js versions, and we can set this on a “per-account” basis if we want.
To install the alt-nodejs group, type:
yum groupinstall alt-nodejs
Here you can see that the command installs all the Node.js versions:
The installation of the entire alt-nodjs group takes a long time, so be prepared to wait a bit. A yum groupinstall is a collection of packages, so you have to wait for all of them to download. Particularly given that you could be installing Node.js versions ranging from 9 to 20, it could be a lot.
While CloudLinux already comes with LVE, you might need to install additional packages to ensure that the LVE manager and utilities are available. In addition, you need to install the passenger module that allows Node.js to integrate with Apache and host Node.js applications using the default web server that you provide with shared hosting. To install these additional packages, type the following command:
yum install lvemanager lve-utils ea-apache24-alt_mod_passenger
Chances are, you’ll find that the first two packages are already installed. But the last one won’t be. If you skip this step, then when you log into WHM to enable Node.js for cPanel.
Apache Passenger is required by Node.js Selector. Please, contact your hoster.
The final step is to ensure that the CageFS virtual filesystem is installed. As with the other packages, chances are that it’s already present. But just to make sure, type:
yum install cagefs
Finally, to complete the installation, restart cPanel as shown here:
systemctl restart cpanel
If you’re accessing the command line using the WHM interface and not through an SSH client, this command will break the connection to your browser and you’ll need to reload the page after a few seconds while cPanel restarts.
Making Node.js Available on cPanel for Your Users
Just because we’ve installed the components of the Node.js Selector, doesn’t mean that your users will automatically see it in their cPanel dashboards. You need to manually enable it from WHM. On the dashboard, type “CloudLinux Manager” inside the search box on the left-hand side as shown here:
This brings up the CloudLinux configuration screen, from where you can enable and disable various aspects of CloudLinux. Thanks to the installation of the packages, Node.js should now be visible as a module:
This will take you to the subsection where you toggle the button enabling Node.js, along with the various versions of the framework. You can use this section to determine to which Node.js versions your users have access. It allows you to enable and disable each version separately:
Save your changes, and you’re done.
Using the Node.js Selector in cPanel
Your users can now access the Node.js selector in cPanel with the versions you’ve enabled. To test this, log into an account’s cPanel dashboard and scroll down to the Software section to select “Setup Node.js App”:
If you already have some Node.js applications on your server, you’ll see them in the following screen and you can manage their Node.js versions. If you don’t have any applications so far, click “Create Application” as shown here:
In the application’s configuration screen, you can select the version of Node.js that you want to install from the dropdown box:
Now your users can start creating Node.js applications from scratch using cPanel!
Using Node.js to Differentiate your Reseller Account
Not many web hosts offer Node.js by default. And most big resellers won’t modify their server configurations just to accommodate your request for Node.js, because they won’t want to reconfigure their server. This is a great opportunity for you to attract those clients who want to run Node.js applications.
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply