cPanel, How to Host a NodeJS Application

If you have a custom NodeJS application for your website, here's how to get it working on web.illinois.edu.

Putting your application on the server

Before you can configure your NodeJS application, you need to get the files to the server. After logging into your cPanel dashboard at https://web.illinois.edu, you can transfer the files by:

Application Configuration

Once your files are in place on the server, you can configure it to launch. From your cPanel dashboard:

  1. Under the Software section, select Setup Node.js App.
  2. Under Create Application, choose Development or Production.
    (Development has less caching and more logging. Production has more caching and less logging.) 
  3. Enter the Application root (the directory where you put the application).
  4. Enter the Application startup file.
  5. You can add environment variables using the Add Variable button.
  6. Once you've saved your application, resolve its package dependencies. You can do this automatically or manually.
  • The NPM package manager does this automatically based on the package.json file packaged with the application, so all that youll need to do is click on the NPM Install button. 
  • If you are familiar with the command line, you can follow the instructions at the top of the page to gain access to the npm and node commands to make additional changes manually, allowing for a great deal of customization.

Application Deployment

Once you have the application configured and the modules installed you can launch it by clicking the Run JS Script on the same page where you configured the application. This executes the application startup file that you defined during setup. 

As Node.js applications have several different options, this can bring up another menu with different options to select depending on the application that youre running. In general, youll want to select the Start option next. 

Finally, you can select the Open option to visit your page, and see your application!

Troubleshooting

Your application generates friendly error pages that can help debug problems, however these are not displayed by default. To turn on friendly error pages, add the following line to your application's .htaccess file:

PassengerFriendlyErrorPages on

Hint: If your application runs at yourdomain.web.illinois.edu/myfolder/myapplication, then the correct .httaccess file is:

<yourhomedirectory>/public_html/myfolder/myapplication/.htaccess

Once your application is ready for production, you should turn friendly error pages back off by removing the line from your .htaccess file.



KeywordscPanel, web hosting, NodeJS   Doc ID91468
OwnerWeb H.GroupUniversity of Illinois Technology Services
Created2019-05-01 12:27:19Updated2019-11-04 11:44:50
SitesUniversity of Illinois Technology Services
Feedback  17   8