NodeJS FTP deploy on shared hosting with Plesk and cPanel

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

Configuring Apache .htaccess
Hello, I beginner in node.js server, on my virtual hosting I need to config .htaccess:
##Hosting sample file
SetEnv GHOST_NODE_VERSION_CHECK false
PassengerStartupFile app.js
PassengerResolveSymlinksInDocumentRoot on
Require all granted
PassengerAppType node
PassengerAppRoot /home/login/domains/example.com/public_html
Options -MultiViews

But if I can set only public_html in PassengerAppRoot string and can`t set /app folder, my web app is not safety?

Very useful, worked perfectly :slight_smile:

4 posts were split to a new topic: Remote database connections