NodeJS FTP deploy on shared hosting with Plesk and cPanel

NodeJS requires a specific setup on your hosting, which is different than the standard Linux or Windows server where you most likely upload everything in the public_html or www folder.

Set Up Site in your Hosting Panel

In this tutorial we will show you how to setup your hosting through the Plesk panel, but it’s quite similar in cPanel.

Create your site in the hosting panel and add NodeJS to it:

FTP account

Then setup your FTP account:

unknown (1)

It should be pointing to this website root folder.

unknown (2)

Node files folder

In your site root create a new folder, called /app
NOTE: Do not create this folder in the public_html folder.

Screenshot_11

this folder will be used for your NodeJS project files.

Setup Wappler Remote Target

The next step is to setup your Wappler target, pointing to the remote hosting. Create a new target and enter your ftp details.
Important - the remote folder should be set to /app - the folder which we created in the previous step:

Click Save.

Switch to the remote target (1) and click publish (2):

Your files will be uploaded to the remote target.

Configuring NodeJS options on your hosting

Now, let’s go back to the Plesk panel, we need to configure NodeJS settings. There are 3 things you need to setup:

  1. Set document root - to the /public folder
  2. Set application root - to the /app folder
  3. Change app.js file to index.js

Screenshot_14

Then click the Enable NodeJS button:

Screenshot_4

You will see a notification that NodeJS has been enabled for your site:

Screenshot_5

Next step is to install the required packages. Click NPM install:

Screenshot_6

Wait for the packages to be installed and click the Restart App after that:

Screenshot_10

And you are done. You have your hosting set up properly for your NodeJS project.

4 Likes

Instructions specific to cPanel.

If you already have this application available in your cPanel, then you can continue with this doc.

Open File Manager

Create a new directory at root level called nodejsapp, you could call it something different if you like, I hade issues with just calling it app
Screenshot 2020-06-03 at 12.34.39

The next step is to setup your Wappler target, pointing to the remote hosting. Create a new target and enter your ftp details.
Important - the remote folder should be set to /nodejsapp - the folder which we created in the previous step: Or whatever name you may have chosen.


Click Save

Switch to the remote target (1) and click publish (2):


Your files will be uploaded to the remote target. Once fully published I would suggest going into the cPanel File Manager and renaming the Wappler uploaded index.js to app.js

Open the Application Manager
Click Register Application

Here are my settings, if in the file manager step you named your directory something other than nodejsapp then adjust the Application Path parameter accordingly.

Click deploy once complete and then back at the main Application Manager screen you should see a button saying Ensure dependencies


Click it.
*If your Application Manager never shows the Ensure dependencies button then your App Settings are incorrect and you need to edit until you get that right, or it will never show itself.

If you get a green done message, great, if you get a red error, you may have to add a file, look here for details Nodejs on cpanel problems and how to fix them

You have to restart the node side to check if this is working however there is no restart button, I just did another publish in Wappler which sent the restart command.

Lastly you need to go back to File Manager and change the name of /nodejsapp/index.js to /nodejsapp/app.js or the passenger module will not over ride the mod_userdir module from Apache, if you had not already done that from earlier.

Browse to your website and it should display fine, if not do a last Wappler publish to send the restart again.

If you do not have the Application Manager in your cPanel you may have to ask your Hosting company to enable it for you site or if you have access to WHM you can provision the Ruby via mod_passenger in EasyApache 4


After this it should be available in cPanel.

10 Likes

Thanks for this, especially to @psweb or taking time to add steps specific to cPanel (which is what I have).

Cheers!

2 Likes

thanks a ton. can’t wait to try nodejs on cpanel :slight_smile:

1 Like

A short update specific to those running webservers with more than one domain.

EasyApache 4 gives an either or choice of multiple profiles through the WHM interface

Because I have some domains on the server that need PHP 7.4 and some that need Node.js 10.15 I provisioned the

And then customized it after provision with all the standard PHP 7.4 engine and PHP Extensions from the cPanel Default profile.
This now allows me to run some domains in PHP and others in Node.js

Thanks Paul. This is all useful information, or might be at some point. I use cPanel hosting but it doesn’t offer Node.js. Do you have the option to use both PHP and Node.js in the same profile? I don’t know if this would be a problem for other reasons, but I can see it being potentially useful.

Also, is Ruby added just because it’s necessary in relation to Node.js?

Hey Tom, i will try explain as far as i can tell.

cPanel accounts without the Application Manager need to have the Ruby via mod_passenger profile activated or you will not have Node.js support. If you have access to the WHM you can activate it yourself in the EasyApache 4 application, or if you do not have WHM access you could ask your hosting provider to activate it on your behalf.

You can run PHP and Node.js in the same profile, which is what I have done, I activate the Ruby via mod_passenger first and then customize the profile to add the PHP Engine and then the PHP extensions I want.
My final profile looks like this

{
   "version" : "0.1",
   "pkgs" : [
      "ea-apache24",
      "ea-apache24-config",
      "ea-apache24-config-runtime",
      "ea-apache24-mod_bwlimited",
      "ea-apache24-mod_cgi",
      "ea-apache24-mod_deflate",
      "ea-apache24-mod_env",
      "ea-apache24-mod_expires",
      "ea-apache24-mod_headers",
      "ea-apache24-mod_mpm_prefork",
      "ea-apache24-mod_proxy",
      "ea-apache24-mod_proxy_fcgi",
      "ea-apache24-mod_proxy_http",
      "ea-apache24-mod_proxy_wstunnel",
      "ea-apache24-mod_ruid2",
      "ea-apache24-mod_security2",
      "ea-apache24-mod_ssl",
      "ea-apache24-mod_unique_id",
      "ea-apache24-tools",
      "ea-apr",
      "ea-apr-util",
      "ea-brotli",
      "ea-cpanel-tools",
      "ea-documentroot",
      "ea-libargon2",
      "ea-libcurl",
      "ea-libnghttp2",
      "ea-libxml2",
      "ea-modsec-sdbm-util",
      "ea-nghttp2",
      "ea-nodejs10",
      "ea-oniguruma",
      "ea-oniguruma-devel",
      "ea-openssl",
      "ea-openssl11",
      "ea-php-cli",
      "ea-php-cli-lsphp",
      "ea-php74",
      "ea-php74-libc-client",
      "ea-php74-pear",
      "ea-php74-php-bcmath",
      "ea-php74-php-calendar",
      "ea-php74-php-cli",
      "ea-php74-php-common",
      "ea-php74-php-curl",
      "ea-php74-php-devel",
      "ea-php74-php-fpm",
      "ea-php74-php-ftp",
      "ea-php74-php-gd",
      "ea-php74-php-iconv",
      "ea-php74-php-imap",
      "ea-php74-php-litespeed",
      "ea-php74-php-mbstring",
      "ea-php74-php-mysqlnd",
      "ea-php74-php-pdo",
      "ea-php74-php-posix",
      "ea-php74-php-sockets",
      "ea-php74-php-xml",
      "ea-php74-runtime",
      "ea-profiles-cpanel",
      "ea-ruby24",
      "ea-ruby24-libuv",
      "ea-ruby24-mod_passenger",
      "ea-ruby24-ruby",
      "ea-ruby24-ruby-devel",
      "ea-ruby24-ruby-doc",
      "ea-ruby24-ruby-irb",
      "ea-ruby24-ruby-libs",
      "ea-ruby24-ruby-wrapper",
      "ea-ruby24-rubygem-bigdecimal",
      "ea-ruby24-rubygem-did_you_mean",
      "ea-ruby24-rubygem-io-console",
      "ea-ruby24-rubygem-json",
      "ea-ruby24-rubygem-minitest",
      "ea-ruby24-rubygem-mizuho",
      "ea-ruby24-rubygem-mizuho-doc",
      "ea-ruby24-rubygem-net-telnet",
      "ea-ruby24-rubygem-nokogiri",
      "ea-ruby24-rubygem-nokogiri-doc",
      "ea-ruby24-rubygem-openssl",
      "ea-ruby24-rubygem-passenger",
      "ea-ruby24-rubygem-passenger-doc",
      "ea-ruby24-rubygem-power_assert",
      "ea-ruby24-rubygem-psych",
      "ea-ruby24-rubygem-rack",
      "ea-ruby24-rubygem-rake",
      "ea-ruby24-rubygem-rdoc",
      "ea-ruby24-rubygem-sqlite3",
      "ea-ruby24-rubygem-sqlite3-doc",
      "ea-ruby24-rubygem-test-unit",
      "ea-ruby24-rubygem-xmlrpc",
      "ea-ruby24-rubygems",
      "ea-ruby24-rubygems-devel",
      "ea-ruby24-runtime"
   ],
   "tags" : [
      "Apache 2.4",
      "Ruby 2.4",
      "Passenger 5.1",
      "PHP 7.4",
      "and Node.js 10.15"
   ],
   "name" : "Ruby via mod_passenger concat cPanel Default",
   "desc" : "The Ruby via mod_passenger profile with added PHP Engine"
}

As long as you have all these you can run both PHP and Node.js.

Although the profile in WHM by default is called Ruby via mod_passenger, we do not need the Ruby part, so just imagine it is called Node.js via mod_passenger as what we need is the mod_passenger module to look for the app.js file used for Node.js and over ride the default of using Apache to read the public_html folder.

Here are some tests I have done with the Node.js activated on the domain.

  1. Add a Node.js app as per the tutorial.
    Browse to the domain, the node.js app runs perfectly.

  2. Add an index.php file inside the public_html folder.
    It ignores the index.php file completely, however if I rename nodejsapp/app.js to any other name then it reverts to reading and parsing the php file.

  3. Add a subdomain of blog to the domain and install wordpress inside the subdomain
    Browsing to the parent domain shows the node app, and browsing to the subdomain shows the WordPress blog part using PHP.

I suppose the short answer is PHP and Node.js can run together as long as the PHP portion is running off a subdomain.

Thanks again for all this information. I can see that index.php might be ignored if app.js exists, and you just enter the domain name, but presumably you’re saying that any php files are ignored - unless you use a subdomain (because it won’t have an app.js file).

With my current hosting provider, I would need to get an account with a cloud or dedicated server. Which hosting provider are you using for these tests?

Because mod passenger drops the ability to see anything in the public_html folder i doubt you would be able to get around it without a subdomain, even though funnily enough my cPanel shoves my subdomain folder inside the public_html folder too, but thats what I think so far.

Testing wise I am being a leech and borrowing a spot on Brian’s VPS, however after getting this working I have configured my dedicated server to the same and it works too as well as another VPS server I have and that also works.
I like inmotionhosting vps personally

My dedicated server is with Afrihost here in South Africa who are great in Africa standards but suck in global standards.

@Hyperbytes will have to tell you where his is. I can’t remember. Lol

Great - thanks again.

1 Like

Mine is UK based

1 Like

Thanks for posting, this is exactly what PLESK users are needing, I’ve been working on this for days now with no success.

I follow instructions to the letter but when I try to publish, I ge the following error:
cd: Access failed: 550 The system cannot find the file specified. (/app)

/app exists on the server, and in the local copy. Anyone else out there had the same issue?

Did you setup the FTP target PLESK as well as in the Remote Directory portion of your Wappler target?

1 Like

Are you sure your FTP user does not point to the /app folder? The user folder should be your domain/site root, inside which you created /app.

2 Likes

my root is /httpdocs which isn’t working, I’m currently setting up another ftp user with a different file path, I’ll post back…

DUH… Looks like I followed the instructions too well! It was the filepath in the project settings window:
Capture

Hopefully it’ll help someone else!

Thanks for pitching in so fast @Teodor and @psweb - much appreciated…

1 Like

If your root is /httpdocs then the remote path in Wappler for the root FTP user should be /httpdocs/app

EDIT: LOL, ditto, haha, sorry i hit post same time as you

1 Like

Hey, two answers are better than none :sunglasses:

Really appreciate your help!

It looks like its running fine now, just testing out some of the server connect stuff and it’s looking pretty good so far. I’m really looking forward to getting my head round this NodeJS stuff, it’s a different environment for sure but the push notification ability for me is a deal breaker - it’ll make a big difference to a lot of the stuff we’d like to create.

@Teodor there are a lot of PLESK / cPanel users out there and this guide will greatly shorten the lead time for creating new projects, it’s going to be a huge help - many thanks for posting this.

2 Likes

42 posts were split to a new topic: Nodejs hosting with Hetzner on KonsoleH