Deploying Node JS or Meteor app on cPanel, WHM based Dedicated Server or VPS







Deploy Meteor or Node JS app on cPanel/WHM

If you are having a dedicated server or VPS, chances are you are not using it to its full capacity and has room for other applications. But, installing non PHP based applications is not easy and straight forward. In this post I will cover how you can install a nodejs application on a cPanel based dedicated server or VPS servers usually available from GoDaddy, Hostgator, BlueHost Etc.. . I will be using our Meteor app NYBR for this tutorial.

Installing Nginx

We will use Nginx as a reverse proxy for apache and our nodejs application.

There were three ways to install Nginx and integrate it with cPanel.

  1. Engintron, Free. This is the one we will be using. Very easy to use, no nonsense. Integrates well with cPanel.
  2. CPNginx, Paid. Did not consider or explore this paid option.
  3. NginxCP, Free. This the one I tried first, it just did not work for me. After trying Engintron, I would never use this.

Before moving any further, lets make sure we have a clean slate and clean any earlier installations on Nginx.

How to uninstall Nginx in CentOS 7 / RHEL 7

1. Stop Nginx service and remove Nginx auto start script

2. Remove Nginx user and it related directory

3. Delete and related Nginx installation directory

4. Remove the created nginx.service script under systemd

How to install Nginx with Engintron

Thats it. Your are done installing Engintron.

You can access Engintron admin page on your WHM under Plugins in side menu.

Engintron admin screen on cPanel

Installing MongoDB on cPanel Centos 7/ RHEL 7

Since we need MongoDB for our Meter app, we will install it now.

1. Add MongoDB repo

and enter

2. Install MongoDB

 3. Configure SELinux

More Info

4. Start and Enable MongoDB

Install NodeJS

Installing Passenger

Enable EPEL Repo

Make sure everything is set properly

Installing Passenger Packages

Install Passenger Nginx Module

Validate the installation 

Installing the MeteorJS Application on cPanel Hosting

Build Meteor App

Change into your meteor directory on your local system and run

Upload myapp.tar.gz to remote host. You can use scp

Now back to the remote system…

It’s always a good idea to run each app under it’s own user name. Since we are using cPanel, lets create a separate account on WHM. Let it be, myappuser.

Extract the application we uploaded before.

Install application dependencies

The application dependencies must be install as the app user

Exit from application user

Create Nginx configuration file

Add following configuration to the file.

Make sure there are no errors in Nginx configuration and restart it

Making Sure Everything is Working

Open your browser and access your app. It should work. If you face any issues, check the error log at

Debugging

  1. Make sure your mongoldb is up and running. If it has a password, be sure to set it.
  2. Check if your Nginx root and passenger_startup_file are correct.
  3. Be sure to set any environment variables your application need in the /etc/nginx/conf.d/myapp.conf file. We have set METEOR_SETIINGS as an example.

Leave a Reply