5 Ways to Grow your Hosting Business Online

Web hosting companies are a vital part of the Internet’s foundation. The total industry value as of 2019 stood at over $56.7 billion, with a Compound Annual Growth Rate of 15.5%. That figure will reach $130 billion by 2025.

Yet despite offering essential services, it can be challenging – but not impossible – for many to stand out. Recent events like the global Covid-19 pandemic have helped to fuel the move towards digital activities. Much potential remains in this space, partially driven by growing Internet penetration rates and the increasing number of startups. 

In the first half of 2019, eight companies alone spent $161 million on promoting web hosting solutions. That represents a 69% increase over the second half of 2018.

Across all of 2019, only two companies decreased ad spend in this sector: GoDaddy and WordPress. The future for web hosting businesses clearly remains bright. 

Let us consider some tactics you can use to grow your business.

Connect with Customers to Elevate your Web Hosting Business

The core of any web hosting business lies in its products and services. What you need to aim for is to go beyond the basics. Building a solid relationship with your customer base is vital to success.

By opening more channels of communication, you can make customers feel valued. At the same time, two-way communications will then provide you with important customer feedback.

1. Serve a Niche Group of Hosting Customers

For those who are new to the business or seeking an avenue of growth to develop, consider niche products. Think of it as aiming to become the biggest fish in a little pond.

If you choose your niche wisely, you might find yourself with very little competition. Aside from helping you build focus, growing with a thriving market can help your reputation immensely.

Some niche segments include game servers, forum hosting, and blog hosting. 

One example of a web host that has mastered a niche is ShockByte, which built its reputation by offering Minecraft servers.

Shockbyte Minecraft server

2. Participate in Web Hosting Forums Discussions

One of the best ways to attract attention is by targeting spaces beyond your confines, such as forums or other exchange platforms. Keep in mind that this strategy needs careful implementation.

Avoid the ‘sales pitch’ on external platforms, as that might quickly get you banned. Instead, take the opportunity to offer assistance and expert advice. Aside from gathering attention, this also serves to demonstrate your industry expertise and leadership.

Screenshot of a helpful interaction within a forum

Some avenues to consider for this include Web Hosting Talk and Reddit. An example of this on the former can be seen in the screenshot above addressing a member’s question on VPS versus WordPress hosting.

The answer is provided by another member who promotes a brand in his signature but offers direct, non-promotional information to help resolve the question at hand.

3. Learn from Competitors to Grow your Web Hosting Business

Imitation is the sincerest form of flattery. When it comes to web hosting, you can also learn by observing what the competition does. Naturally, this includes the technologies that form the foundation of their business.

Using a simple tool at WHSR, you can easily strip a website down to see what it’s running on. Other things to note are advertising strategies, customer testimonials, and even areas they are building towards.

A demonstration of this can be observed when we use that tool to analyze the WP Engine site. Below, you can see that they use various analytics tools to understand their visitors better:

Screenshot showing analytical data from WP Engine

On average, expect to spend 10%-20% of your resources towards experimentation of new technologies or marketing strategies.

4. Soft-promote your Hosting Services with Helpful Content

Aggressive advertising to attract new customers can end up costing more than you expect. Thankfully, there are more holistic (and realistic) methods of growing your potential customer base.

The most desirable way of doing this is through organic search rankings. Build content that can help users solve problems while subtly inserting your products and services in-between.

To do this, you need to know what the pain points are that web hosting users face. Having identified that, you can build content around the solutions you offer.

While this may seem challenging, it has been demonstrated to work quite well. For example, Kinsta built helpful articles that targeted WordPress error messages (example) and pulled in tons of potential customers to their blog as a result. 

A further example of this can be observed in the following Ahrefs analysis of Kinsta. We can see data indicating that Kinsta ranks for more than 7,900 error-related search terms and pulls in thousands of visitors each month from the United States alone.

Ahref analysis of Kinsta data

5. Leverage Influencers & Celebrities to Establish Trust in Your Hosting Solution

Celebrity endorsements and influencer reviews are giant trust markers and can offer better ROI than traditional marketing channels.

To do this correctly, make sure you work with the right influencers. Choose those more relevant to your niche or brand and make sure they have a sufficiently large following to make an impact.

Take the case of 20i, which tries to leverage on the popularity of Georgie Barrat, a tech journalist and presenter on The Gadget Show. The partnership can also serve as an endorsement of sorts.

Screenshot showing influencer Georgie Barrat on the 20i homepage

Final Thoughts

Growing a web hosting business can be challenging, though this is true for virtually every industry. Look past the basics and examine details in various areas to get a more profound sense and understanding of the business.

Minor adjustment in detail or simply a shift in strategy does not necessarily have to be big to have impact. Take things progressively and monitor the changes resulting from your efforts – you might be surprised by the results.

How to Spot Phishing Attempts

We all know that there exists bad people on the Internet that want to steal our personal information for whatever nefarious reason they may have, right? Sometimes they want our bank account login, which makes sense, but other times they want something that maybe makes less sense, like a Facebook login. No matter what the reasons are that motivate these people, any attempt they make to effectively trick you into providing the information they are after is called “phishing.”

Phishing comes in many forms, we’re going to discuss the most popular ones and also give you the knowledge necessary to identify and protect yourself from these attempts; online and in real life.

What Exactly is Phishing?

Phishing is, in practice, the attempt to trick someone into providing their personal data (be it account credentials, credit card numbers, or other sensitive information) by fraudulently presenting yourself as a trustworthy institution or individual who needs the information for legitimate purposes.

A simple example of phishing would work like this:

  1. I receive an email that has my bank’s logo at the top of the email and it says that my password has been disabled due to multiple failed login attempts. It says that my account security is very important to them and I need to now restore access to my account by clicking on the link below.
  2. I click on the link and it takes me to a website that looks exactly like my bank, and so I go ahead and put in my username and password. But then it doesn’t log me in, instead it might display some kind of error, but at this point it really doesn’t matter, because…
  3. I have now provided my bank account credentials to a phisher, they can instantly log into my bank account, change the password to lock me out, and transfer away my life’s savings.

Here’s an actual phishing email we recently received attempting to do exactly what’s described above:

Example of a phishing email.

In a nutshell, that’s how phishing works. Though these scams have become more elaborate over time, including being attempted via text message and telephone: “Hello, this is your bank calling. We need to discuss an important issue with you about your account, but first we need to verify your identity. Please provide your username and password…”, the general purpose and execution of these scams remains basically the same. 

How to Protect Yourself From Phishing

As you can see, phishers have multiple ways to attempt to trick you, but there are some fundamental things to keep in mind that will protect you and prevent any phisher from being able to take advantage. 

  • Always consider the source. That email from “your bank” that asks for your account credentials is most likely from some email address completely unrelated to your, or any, bank. For example, here’s a closer look at that email we showed you earlier, note that the sending email is simply a random email address:
Example of a phishing email header
  • And again, always consider the source. If “your bank” calls you and asks for any sensitive information, consider that a phishing call. But if you call your bank, then in that instance you are the source and you would be able to consider providing account-specific information related to the reason that you made the call. 
  • Never click on any links contained in suspicious-looking emails. Sometimes these links can contain executable files that would compromise whatever device you were using when you clicked. 
  • Exercise good judgement. If something looks a little bit off, then it’s probably a phishing attempt. This can include misspelled words, bad grammar, or unusual phrases contained in emails from “legitimate” businesses.

When in doubt, the best bet is often to just reach out to the actual alleged sender; call your bank and ask if they sent you that email. As always, it’s better to be safe than sorry.

If you happen to ever spot a phishing email that claims to be from cPanel or sends you to a cPanel login page, please forward that email to cs@cpanel.net with the full email headers so we can properly investigate that phishing attempt.

And for more information about phishing, visit https://www.consumer.ftc.gov/articles/how-recognize-and-avoid-phishing-scams

If you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit.

WP CLI: Install and Manage WordPress® on the Command Line

WordPress is incredibly easy to use with its intuitive graphical interface but it’s not ideal for server administrators and hosting providers who manage hundreds of sites. WP-CLI (WordPress Command Line Interface) is a powerful tool that can control every aspect of WordPress from the command line.

When  you’re tasked with updating or installing a plugin, managing multiple WordPress sites with the command line and scripting is more efficient. In this article, we’ll show you how to install WP-CLI and highlight some of its most useful features, including how to install, update, and manage WordPress core, plugins, and themes on the command line.

How to Install WP-CLI

WP-CLI is a self-contained PHP app that can be installed both by server administrators and ordinary cPanel users.

  • Server administrators can make WP-CLI available to all of the server’s users.
  • cPanel users can install it in their home directory or a WordPress site’s directory to control their sites.

To install and use WP-CLI, you will need access to your server’s command line. Administrators with root access can log in with SSH. cPanel users can log in with SSH if it’s available or cPanel’s built-in Terminal.

First, we need to download WP-CLI to the server with:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Before we can run it, we need to provide execute permissions with:

chmod +x wp-cli.phar

You can learn more about chmod and file permissions in How to Assign Permissions to Files and Folders in cPanel.

Setting Up WP-CLI as the Root User

To allow every user to run WP-CLI, we have to move it to a directory in the system’s PATH.

mv wp-cli.phar /usr/local/bin/wp

This:

  • Moves the file to “/usr/local/bin.”
  • Renames it to “wp” for convenience, although you can also choose another meaningful filename.

All users should be able to run WP-CLI from as “wp.”

Setting Up WP-CLI as a cPanel User

cPanel users without root access can’t move files into a directory in PATH, but they can run it from their home folder or in a WordPress site’s directory.

To run it from your home directory, you can tell WP-CLI which WordPress site to control with the “–path” option. For example:

./wp-cli.phar config list --path=/home/user/public_html/

If you move WP-CLI into the WordPress site’s directory, you don’t have to supply a location with “–path,” but you will need to specify the directory that contains the executable, using “./“ for the current directory.

/home/user/public_html/wp-cli.phar config list

To make it easier to use, you can create an alias, a command-line shortcut :

alias wp='~/wp-cli.phar’

The shell will replace “wp” with “~/wp-cli.phar”, allowing you to enter “wp” rather than the full path to the executable.

You can make the alias permanent with:

echo "alias wp='~/wp-cli.phar'" >> .bashrc

We’re adding the alias command to your account’s .bashrc configuration file so that it runs whenever you log in.

How WP-CLI Commands Work

WP-CLI commands are composed of a primary command followed by subcommands for controlling particular aspects of a WordPress site.

For example:

wp help 

Here “help” is a command, which has subcommands such as:

wp help core

This prints help information for “core” management features. The tool has an excellent built-in help and documentation system. If you’re unsure which commands you can run or what they do, help should be your first recourse.

4 Incredibly Useful WP-CLI Commands

There are over 40 commands and hundreds of subcommands. You can read the full list in the documentation, but we’d like to highlight a few of the most useful.

  1. Reading and Writing Config Files
  2. Changing WordPress User Passwords
  3. Installing WordPress core, themes, and plugins
  4. Back-up and Optimize the WordPress Database

Reading and Writing WordPress’s Configuration

The config command can read and write WordPress’s configuration, which is stored in the wp-config.php file.

To see the configuration variables in a site’s wp-config.php file:

wp config list

To edit individual configuration variables such as the database name:

wp config set DB_NAME new_name

To generate a new wp-config.php file with pre-configured values:

wp config create --dbname=user2_wp --dbuser=user2_wp --dbpass=new_password

Changing WordPress User Passwords

In our recent article, Fixing WordPress Login Errors With cPanel, we explored how to change user passwords by editing the database. Here’s a faster way to replace lost and forgotten WordPress passwords.

wp user update USERNAME --user_pass="new_password"

Although this method is faster, it is not as secure because the user’s plaintext password is stored in your shell history. You can delete the shell history entries by using the up arrow to select the command and pressing Ctrl-U to delete it.

Installing WordPress Core, Themes, and Plugins

One of the most useful aspects of controlling WordPress from the command line is the ability to install everything from a plugin to a full WordPress site. 

Let’s start with a plugin:

wp plugin install hello-dolly --activate

To install without activating, omit the “–activate” option. To find the correct name for a plugin, open its page in the WordPress plugin catalog and copy the URL slug. In the example, we used the Hello Dolly plugin and copied the URL slug from its web page: https://wordpress.org/plugins/hello-dolly/.

To install a theme:

wp theme install twentytwenty --activate

You can also  “uninstall,” “delete,” and “update” plugins and themes. The update feature is particularly useful on sites with many plugins:

To update all of a site’s plugins at the same time:

wp plugin update --all

Finally, to install a new WordPress site in seconds:

wp core install --url=example.com --title="A New Site" --admin_user=frank --admin_password=astrongpassword --admin_email=frank@example.com

Running this on the command line stores the plaintext admin password in the shell history, but you can delete it as described in the previous section.

Back-Up and Optimize The WordPress Database

As we explained in How to Back Up and Restore MySQL® Databases in cPanel, it’s straightforward to dump your site’s MySQL database in the cPanel interface. However, if you prefer to back up from the terminal, use:

wp db export --add-drop-table

The “–add-drop-table” option ensures that data is correctly replaced when restoring the backup. Export creates an SQL file with a filename based on the date and database name. To specify a different filename, add it to the end of the command:

wp db export --add-drop-table database-backup.sql

To restore the database, import the SQL file with:

wp db import database-backup.sql

Importing is a destructive action. It will irretrievably delete any data that was added to the database after the backup was made.

Finally, you can optimize or repair the database. Optimizing reorganizes the way data is stored to speed up reading and writing:

wp db optimize 

Repair attempts to fix damaged database tables. It is often worth trying when you suspect database corruption or in a White Screen of Death situation where the WordPress interface is not working.

wp db repair

Fast and Efficient WordPress Multisite Management with WP-CLI

WP-CLI is an essential tool for anyone who hosts and manages large numbers of WordPress sites. It can substantially reduce the time and effort needed to carry out regular maintenance tasks.

In this article, we focused on running commands manually, but all the commands discussed and many more can be used in scripts to automate complex workflows. WP-CLI can also be combined with cron to schedule WordPress management tasks. We explained how to automate web hosting tasks with cron in How to Configure a Cron Job.

If using the WP-CLI still seems a bit daunting, cPanel has added the most used WP-CLI commands to WordPress Toolkit for cPanel  in Version 92.  Launching a site,  managing plugins and themes, and more,  are all just a click away.  Discover all the features of  WordPress Toolkit.

As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit.

Branding cPanel Reseller Hosting: A Guide for Reseller Hosts

Does your reseller hosting business have a brand identity that sets it apart from the competition? In a ferociously competitive hosting industry, a custom brand can help your hosting services to stand out from the crowd, which is why cPanel & WHM® makes it straightforward to customize the cPanel® interface and establish a unique visual identity.

What is Reseller Branding in cPanel?

cPanel & WHM provides features for administering web hosting servers (WHM) and managing web hosting accounts (cPanel), but we also support a third type of account: reseller hosting. Unlike standard cPanel accounts, resellers can access some WHM features, and they can create and manage cPanel accounts for other users.

Reseller accounts are great for people who want to provide web hosting services but don’t want or need a full server’s resources. With cPanel reseller hosting, the reseller rents server space from a hosting provider, then parcels it out to clients, each of whom has a cPanel account which can be customized by the reseller.

cPanel & WHM provides two user interface customization options to resellers :

  • Brand customization in WHM.
  • Themes that override the default theme with brand colors, text, and icons.

In this article, we’ll use both to build a unique brand for cPanel reseller hosting with custom colors, content, and icons.

What You Need to Brand Your cPanel Reseller Hosting Interface

Before we get started, you’ll need the following:

  • A cPanel reseller account; we’ll be using features from both WHM and cPanel.
  • An understanding of HTML and CSS, although we’ll explain what you need to know to customize themes.
  • Command-line access. Most customizations can be made in cPanel & WHM, but a small number require shell access.
  • Brand assets, which might include a logo, color scheme, and template content.

With that in place, let’s begin!

Reseller Brand Customization in WHM

WHM’s Customization feature allows resellers to modify key aspects of the interface. This is where you choose a company name, logo, and other branded interface elements.

Log in to WHM with your reseller account and navigate to Customization, which you will find under cPanel in the sidebar menu.

On this page, you can:

  • Enter a company name, which will appear in the top left of cPanel’s navigation bar.
  • Upload a company logo for the primary and webmail interfaces.
  • Set a favicon, the small image in browser tabs.

You can also set links to your company’s help and documentation pages, which, by default, appear in the footer of cPanel pages.

Under each field in the form is information about the type of asset you should provide. For example, your logo should be approximately 250 px wide and 50 px high to fit cPanel’s layout. Ignoring this guidance can have an undesirable impact on the interface.

Once you have added your brand’s assets, open cPanel to see your newly-branded web hosting interface.

As you can see, we’ve added a new logo and a matching favicon. Customization is often all resellers need to brand client cPanel accounts, but it’s possible to change almost every design element. In the next section, we’ll show you how to create a theme and make it the default.

cPanel Reseller Hosting with a Custom Branded Theme

cPanel includes a default theme called Paper Lantern. We’re going to create a theme that overrides aspects of Paper Lantern with reseller branding. You could make a new theme from scratch, but overriding an existing one is more accessible to people who aren’t developers.

We’ll be working in the File Manager, so log in to cPanel with your reseller account and open File Manager.

First, we need to create a directory to contain our theme. Custom themes are stored in the var/cpanel/reseller/styled directory. If the styled subdirectory doesn’t exist, create it with the +Folder button.

Inside the styled directory, make a new directory and give it an appropriate name for your theme. Don’t use spaces in the filename. Use underscores instead, and cPanel will convert them to spaces in the interface.

Use the +File button to create a file inside your theme directory called styles.css. Be sure to use that filename, or your theme won’t work.

Open styles.css with the Edit button in the toolbar. We’re going to add CSS directives to override the defaults. Add the following CSS to your styles.css file and click Save in the toolbar.

.navbar-header {background-color: #3f7cac;}

This code:

  • Identifies the navigation bar with the .navbar-header CSS selector.
  • Defines the property we’d like to change, in this case, background-color.
  • Supplies a color as a hex color code.

We don’t have the space to go into too many details about CSS here, but you can find lots of information at the Mozilla Developer Network.

In the cPanel User dropdown menu, select Change Style, and click Apply on the theme you have just created.

Now that you are running your new theme, the navigation bar will change to the color you selected in CSS, in our case, a light blue.

You can change the color of most interface elements in this way, but there’s one problem. How do you know which CSS selector to use? We’ll explain how to find out with another example.

Finding CSS Selectors for cPanel Reseller Themes

We had a light blue navigation bar in the last image, but the menu section headers were a different color. Ideally, we want them to match, so we have to apply the same CSS transformation.

Fortunately, web browsers make it quite easy to find the right CSS selector. We’ll show you how it’s done in Google®  Chrome™ , but other browsers support a similar method.

Open cPanel and right-click on the element you would like to modify. Select Inspect from the menu.

The browser opens its web inspector with the code for the element you selected highlighted. To the right is a list of the CSS directives that influence that element. Find the one that controls the property you would like to change.

In this case, the selector is .widget-heading, so we can add the following CSS to our styles.css file.

.widget-heading { background-color: #3f7cac;}

Save the file and refresh cPanel. The navigation bar and menu items now match.

Finding the right CSS selector isn’t always so straightforward, but once you are familiar with the web inspector, you will quickly identify theme elements and write CSS to change them.

Customizing Reseller Theme Content in cPanel

In addition to modifying a reseller hosting accounts’ appearance, you can also insert or change text on cPanel pages. The page content is controlled by templates, and there are several that influence the content in the main page area.

  • Global header and footer templates, which affect every page in cPanel. They are named ‌global_header.html.tt and ‌global_footer.html.tt.
  • Feature-specific header and footer templates, named after each feature. For example, the FTP page’s templates are called ftp_page_header.html.tt and ‌ftp_page_footer.html.tt

Header templates control content at the top of pages and footer templates at the bottom. Other cPanel features and interface elements have similar templates, which are described in Guide to cPanel Interface Customization – UI Includes.

To add content to cPanel pages, we create the template files in the ‌var/cpanel/reseller/includes/ directory inside the reseller’s hosting account. The includes directory does not exist by default, so you may need to create it.

Let’s add a welcome note to the top of cPanel pages. Follow the same File Manager process outlined in the previous section to create a file called global_header.html.tt in ‌var/cpanel/reseller/includes/.

Open ‌global_header.html.tt in the File Manager text editor, enter the following and click save.

<div style="background-color: #553555; color: #fff; font-weight: bold; padding: 15px; text-align: center;">Welcome to your cPanel account.</div>

Refresh cPanel, and the new header message will be displayed at the top of every page.

In this way, you can add HTML, CSS, and JavaScript to any of cPanel’s reseller templates.

Customizing cPanel Reseller Icons

Our icons are designed to help users understand what cPanel’s tools do, but you can change them if they don’t work with your custom theme. We’ll replace the File Manager icon with a flat design that matches our custom logo.

You will need an image file that:

  • Is saved in the png format.
  • Has a maximum size of 48×48 pixels.
  • Has a transparent background.

Icons must be named for the feature they are associated with. In cPanel, features have an app_key, which is used in templates, icons, and other associated assets. You can find the app_key for icons in Guide to cPanel Interface Customization – Appkeys.

The app_key for File Manager is file_manager, so we’ll name our icon file_manager.png. Icons are stored in an icons directory within a custom theme. Navigate to your custom theme in File Manager and create a folder called icons.

Move into the new directory and use the File Manager’s Upload button to upload your icon image.

Finally, we need to generate the image sprite that cPanel uses to serve icons efficiently. Log in to the reseller account with SSH or open cPanel’s Terminal interface.

Run the following command, replacing “Reseller_Hosting_Theme” with the name you chose for your theme.

/usr/local/cpanel/bin/sprite_generator --theme paper_lantern --style Reseller_Hosting_Theme

Refresh cPanel, and your new icon will be displayed on the main page.

Make Your Reseller Hosting Theme the Default

The final step is to make the custom theme the default so that when resellers create a cPanel account, it has custom branding. However, before we do that, let’s create a preview image for the Change Style interface.

Take a 500×500 pixel screenshot of your new-look cPanel. Save the file as preview.png and use File Manager to upload it to the theme’s folder.

Select Change Style from the navigation bar’s user menu, and you will see the custom theme displayed with its new preview. While you’re here, click the Set as Default button to make it the default for new cPanel accounts.

In this article, we’ve shown you how to transform your web hosting interface into a custom branded UI with unique colors, content, and icons. cPanel & WHM’s flexible theming system gives hosts the tools they need to build a vibrant and impactful branded reseller hosting experience with a coherent and memorable visual identity.

As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit.

How to Host a Node.JS Application With cPanel

Node.js hosting was once a complicated business, especially on multi-user web hosting servers. However, with cPanel & WHM’s Application Manager, installing JavaScript applications and configuring Node.js environments is a breeze, empowering web hosts to offer intuitive Node.js hosting services with an easy-to-use graphical interface. 

In this article, we explain how to activate cPanel’s Application Manager and how to install, register, and manage Node.js applications. 

Getting Started With the cPanel Application Manager

cPanel users can register Node.js applications and associate them with a domain in Application Manager.  To offer this feature to hosting users, server administrators should first install a handful of support packages and ensure that Application Manager is activated.

We’ll use WHM’s Feature Manager to turn on Application Manager.  Open Feature Manager, which is under Packages in the WHM sidebar menu. 

Click the Edit button under Manage Feature List with the Default list selected in the dropdown menu. 

Enter Application Manager in the search field, and verify that its entry in the feature list is checked. If it isn’t, click the adjacent box and then Save at the bottom of the page. 

Next, we’ll install the software that allows cPanel to run and manage Node.js applications, including the mod_passenger app server and EasyApache4’s Node environment. You will need to log in as root with SSH to install the software:

yum install ea-ruby24-mod_passenger ea-apache24-mod_env ea-nodejs10

Application Manager is now available in user cPanel accounts and ready to host Node.js applications. 

Creating an Application in the cPanel Application Manager

Hosting applications with cPanel is a two-step process:

  1. Install the app on the server. 
  2. Register it with Application Manager.

We’ll look at registering an application in the next section, but first we need to install it on the server. Users of the Git™ version control system could clone a repository with its command-line client or cPanel’s Git Version Control interface. However, to illustrate the process, we’ll create a simple single-file application.

Log in with SSH as a cPanel user and create a new directory in their home directory. 

mkdir nodejsapp

You can call the directory anything you want. This is where your app’s code files will live. Create a file called app.js in this directory with your preferred text editor. cPanel expects the application’s entry point to be called app.js, so it’s best to stick with the standard naming convention unless you have a good reason to change it

Paste the following code and save the new file. 

const http = require('http')
const hostname = '127.0.0.1';
const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World! I am your new NodeJS app! n');
}); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`);
});

The code sets up an HTTP server on port 3000. It responds to web requests with the message: “Hello World! I am your new NodeJS app!”  

We could go straight to the registration step, but let’s make sure the app works first. Run the following command, which executes our mini-app with EasyApache’s Node.js installation. 

/opt/cpanel/ea-nodejs10/bin/node app.js

All being well, you will see a message that says:

Server running at http://127.0.0.1:3000

Finally, open a new terminal window and log in to your server as the same cPanel user. We’ll use the curl HTTP client to send the app a request. 

curl http://127.0.0.1:3000

If it responds with “’Hello World! I am a NodeJS app on cPanel,” you can move on to the next stage: registering your Node.js app with cPanel. 

Registering Your Node.JS Application in the cPanel Application Manager

Registering tells the Passenger app manager and cPanel where to find your application and which domain you would like to use. 

In cPanel, open the Application Manager, which you’ll find under Software on the main page. 

Click the Register Application button.

In the Application Configuration table, we need to provide four pieces of information:

  • Application Name: A display name for the application. You can choose any name, but it must start with a number or letter, and it can’t contain periods.
  • Deployment Domain: The app’s domain name. The domain must already be associated with the cPanel account. 
  • Base Application URL: The app’s home page will be available at the deployment domain + the base URL. For example, if the Deployment Domain is “example.com” and you enter “nodeapp” in this field, the app will be served from “example.com/nodeapp.” The URL extension does not have to be the same as the directory that stores the app’s files. 
  • Application Path: The location of the app’s files relative to the user’s home. In our example, we created a directory in home called “nodejsapp,” so we’d enter “nodejsapp” here.

The Deployment Environment selector indicates whether the app is under development or ready for deployment in a production environment. 

Underneath the Application Configuration table is an interface for configuring environment variables. We’ll look at them in greater depth in the next section. 

For now, we’ll click the Deploy button at the bottom of the page, and cPanel will configure the app’s environment and domain. Once it’s finished, you can open your new app in a web browser at the URL you just configured: “example.com/nodeapp” in our examples. 

Unlike a real app, our one-pager has no external dependencies. If it did, cPanel Application Manager would display the Ensure Dependencies button for one-click installation. The button is only available for apps with a package.json file that lists dependencies. 

 If you’re following our examples and would like to see Ensure Dependencies in action, add a file called package,json to the app’s directory with the following contents:

{ "name": "nodejsapp", "version": "1.0.0", "description": "A Node App", "main": "app.js", "author": "", "license": "ISC", "dependencies": { "express": "^4.17.1" }
}

As you can see, we have listed the Express web framework as a dependency.  The Ensure Dependencies button should now be available in Application Manager. When you click it, cPanel installs Express and any applications and libraries it depends on. 

Adding Environment Variables to Your Node.JS App’s Environment

Environment variables are name-value pairs that store a chunk of information. They work much like variables in programming, except that they are not internal to the program but part of its external environment.  Servers use environment variables to hold useful configuration data. 

For example, CentOS uses the PATH environment variable to store a list of directories that contain command-line programs. When you enter a command like “ls,” the shell looks through those directories for an executable file with that name.  If there was no PATH variable, you’d have to enter the full path of every command:  “/usr/bin/ls” instead of just “ls.” 

The server administrator can change the PATH environment variable, controlling the directories the shell looks in without modifying its internal code.  With cPanel’s Application Manager, you can add environment variables to your Node.js app’s environment to configure its behavior in the same way. 

In our simple app.js file, this line of JavaScript tells the app the port it should listen for connections on. 

const port = 3000;

In reality, a developer is unlikely to know the correct port when they write the code.  To give users more flexibility, they could tell the app to look in its environment for a variable called PORT and to use its value when setting up the app. 

In Node.js, the JavaScript code looks something like this:

const PORT = process.env.PORT || 3000;

This sets the app’s internal PORT variable to the value of the environment variable called PORT or to a default of 3000 if an environment variable isn’t set. 

Now the user can tell the app which port to bind to by setting a PORT variable in the app’s environment. To do this in cPanel’s Application Manager, find the Environment Variables interface beneath Application Configuration and click Add Variable.

Enter a variable name and value, and click Save. 

Editing Your Node.JS Application

You can edit a Node application’s registration configuration in the Application Manager.

Click the Edit link in the Actions column. In this interface, you can edit all the values you set when first registering your application, including the environment variables. 

Uninstalling Your Node.JS Application

To uninstall or “unregister ”a Node.js application from cPanel, click the unregister link at the right of the Application Manager table. 

When you unregister an application, cPanel removes it from the list, deletes its configuration file, and dissociates it from the domain. cPanel does not delete the application’s files, but you are free to delete them yourself in File Manager or on the command line. 

Bring Node.JS Hosting to Your cPanel Server

PHP remains the most widely used server language by a large margin, but Node.js, JavaScript, and web frameworks like Express, Meteor, and Nest are increasingly popular with web developers and tech-savvy users. cPanel and WHM’s Application Manager makes it easy for web hosts to support Node apps and JavaScript-focused users on their platform.

As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit.