This document describes how to install a
Node.js web application.
- cPanel Technical Support does not provide assistance with the steps in this document.
- We recommend that only experienced system administrators perform these steps.
- We are not responsible for any data loss.
- We recommend that you perform the steps in this document via the command line as a cPanel user unless otherwise specified.
- You can also perform these steps in cPanel's Terminal interface (cPanel >> Home >> Advanced >> Terminal).
- In this document,
nodejsapprepresents the application's name and
3000represents an open firewall port.
For more information, read the
Install a Node.js application
Before you begin, make certain that your hosting provider installed the following EasyApache 4 RPMs on your server:
This module disables Apache's
We also recommend that your hosting provider install the
Install the application.
To install an application, perform the following steps:
- Log in to the server via SSH as a cPanel user.
Create the application's directory, relative to your home directory. To do this, run the following command:
Change to the application's directory.
app.jsfile with a text editor. This is the application's default startup file.
We strongly recommend that you create the file with this exact name because Passenger searches for this filename when it executes. If you create a startup file with a different name, you must specify the filename in the
httpd.conffile. To do this, follow the directions in the Create a custom startup file section below.
Add the application's configuration to the
app.jsfile. This will resemble the following example:
Test the application.
After you install the application, we recommend that you confirm it's active. To do this, perform the following steps:
Run the following command:
The output will resemble will the following example:
Open another terminal window and log in to the server via SSH as the same cPanel user.
Run the following command:
The output will resemble the following example:
If you wish to export the
/opt/cpanel/ea-nodejs10/bin path to your environment, add the following line to your
Register the application.
After you install the application, register it. To do this, use cPanel's Application Manager interface (cPanel >> Home >> Software >> Application Manager).
After you register the application, you can access the application in a web browser with the following URL:
In this example,
example.com represents your website.
Restart the application.
When you want your application to restart after you edit it, create the
restart.txt touch file in the application's
tmp directory. This file directs
mod_passenger to restart the application after you modify it. This action applies your changes to the application.
- You must touch the
restart.txttouch file each time that you want
mod_passengerto restart the application.
You must manually create the
tmpdirectory. For example:
Create a custom startup file.
Passenger searches for the
app.js filename when it executes. If you create a startup file with a different name, you must create an include file and specify the startup filename there. If you don't do this, your application won't function.
To specify the new filename, perform the following steps:
- Create the
/etc/apache2/conf.d/userdata/ssl/2_4/user/domain.nodejs.conffile with a text editor.
PassengerStartupFilevariable and the filename as its value in a virtual host container. This will resemble the following example:
httpd.conffile. To do this, run the following command:
Restart Apache. To do this, run the following command: