I set up a new subdomain and enabled Passenger, but I am having some trouble getting it to work. I have done this previously, with success, on other domains.
Here is all of the seemingly relevant set-up and some sanity checks:
[charlotte]$ pwd
/home/<redacted>/<redacted>.<redacted>.com
[charlotte]$ ls -la ..
total 124
drwx--x--- 9 <redacted> <redacted> 4096 Sep 3 16:27 .
drwxr-x--x 1929 root root 53248 Sep 3 16:31 ..
-rw-r--r-- 1 <redacted> <redacted> 260 Oct 2 2019 .alias
-rw-r--r-- 1 <redacted> <redacted> 81 Oct 2 2019 .bash_profile
-rw-r--r-- 1 <redacted> <redacted> 252 Sep 3 15:16 .bashrc
drwx------ 2 <redacted> <redacted> 41 Sep 3 15:14 .cache
-rw-r--r-- 1 <redacted> <redacted> 417 Oct 2 2019 .cshrc
drwxrwxr-x 8 <redacted> <redacted> 4096 Sep 3 15:20 .nvm
drwxr-xr-x 10 <redacted> <redacted> 122 Sep 3 15:13 .php
-rw------- 1 <redacted> <redacted> 10157 Sep 3 16:27 .viminfo
drwxr-xr-x 5 <redacted> <redacted> 52 May 23 2019 Maildir
dr-xr-x--- 3 <redacted> <redacted> 47 Sep 3 15:09 logs
drwxr-xr-x 4 <redacted> <redacted> 102 Sep 3 16:27 <redacted>.<redacted>.com
[charlotte]$ ls -la
total 16
drwxr-xr-x 4 <redacted> <redacted> 102 Sep 3 16:27 .
drwx--x--- 9 <redacted> <redacted> 4096 Sep 3 16:27 ..
-rw-r--r-- 1 <redacted> <redacted> 104 Sep 3 16:25 .htaccess
-rw-rw-r-- 1 <redacted> <redacted> 29 Sep 3 15:21 HelloWorld.js
-rwxr-xr-x 1 <redacted> <redacted> 312 Sep 3 16:27 app.js
drwxr-xr-x 3 <redacted> <redacted> 76 Sep 3 15:10 public
drwxrwxr-x 2 <redacted> <redacted> 24 Sep 3 15:28 tmp
[charlotte]$ cat ../.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[charlotte]$ cat .htaccess
PassengerNodejs /home/<redacted>/.nvm/versions/node/v12.22.12/bin/node
PassengerFriendlyErrorPages on
[charlotte]$ which node
/home/<redacted>/.nvm/versions/node/v12.22.12/bin/node
[charlotte]$ node -v
v12.22.12
[charlotte]$ node HelloWorld.js
Hello World!
[charlotte]$ cat app.js
var http = require("http");
console.log("Starting server...");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World. This page is running Node.js version: ");
response.write(process.version);
response.end();
}).listen(80);
When I try to visit the site, I get one of two error messages (that seem to switch at random, upon reloading):
Web application could not be started
An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger. Please read this article for more information about this problem.
Raw process output:
*** ERROR ***: Cannot execute /usr/bin/node: No such file or directory (2)
Web application could not be started
An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger. Please read this article for more information about this problem.
Raw process output:
*** ERROR ***: Cannot execute /home/username/.nvm/versions/node/v12.22.12/bin/node: No such file or directory (2)
I started with a completely clean subdomain. I went through all the steps in the guides provided by DreamHost. I installed and tested nvm, then I installed and tested node. I set the permissions and aliases, as explained in the docs. Then I created the example app.js file. Once that failed, I turned on the friendly error messages in .htaccess (which more proves it is reading the file, as I was not getting the detailed error report prior to this change). I then compared things to another, working, subdomain that I have.
For what it's worth, running touch tmp/restart.txt
and/or touch .htaccess
seems to increase the likelihood of the error message switching from one form to the other.
References:
- https://help.dreamhost.com/hc/en-us/articles/217185397-Node-js-overview
- https://help.dreamhost.com/hc/en-us/articles/360029083351-Installing-a-custom-version-of-NVM-and-Node-js
- https://help.dreamhost.com/hc/en-us/articles/360043107192-Troubleshooting-Node-js
- https://help.dreamhost.com/hc/en-us/articles/216635318-Enabling-Passenger-for-Node-js
- https://help.dreamhost.com/hc/en-us/articles/216635268-Passenger-troubleshooting