sample Nodejs app provided by cPanel for beginners NOT working

robwebdev

Member
May 27, 2018
5
0
1
Hong Kong
cPanel Access Level
Root Administrator
The "getting started" sample app provided by cPanel itself (I'm referring to this one: Node.js Hosting Configuration and Installing Node.js Apps | cPanel Blog) is not working on my system. I've followed the instructions to the letter and what the result is simply the index to my directory showing my 'app.js' file and 'package.json'. I have set the enviroment variable etc. I ran

/usr/sbin/httpd -t -D DUMP_MODULES

and did NOT see ea-apache24-mod_env
If that module is required, is there anything special I should know before installing it?
BUT I then tried to install it via "yum install ... or something to that effect ea-apache24-mod_env -> it said it was ALREADY installed.

Please help.
 

Attachments

Last edited:

robwebdev

Member
May 27, 2018
5
0
1
Hong Kong
cPanel Access Level
Root Administrator
SOLUTION: this worked for me:

the problem was I needed to make some changes to my .htaccess file in my public_html directory. Note that it is a hidden file so I had to enable "show hidden files" in the settings for the public_html directory so that I could edit this file. here is what I put in my .htaccess file:

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]

where "XXXXX" is the port number, for example 3001. Note also that I had already gone through the process of registering my app and setting, via the user interface, the environment variable of PORT to 3001

Hope this helps, and the the original cpanel tutorial should have been clear about these things, let us know, give us some hints, we're naturally going to be wanting to see it live on our site ... it's not just in development in this context at all: we're hosting and using cpanel!
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,092
779
313
cPanel Access Level
Root Administrator
Hey there! I'm glad you were able to come up with a workaround. We do mention that Apache module is necessary in this command on that page:

Code:
yum install ea-ruby24-mod_passenger ea-apache24-mod_env ea-nodejs10
so you still may want to install that and see if that changes the behavior.