This article describes how to enable Node.js to work with Passenger using the DreamHost panel.
Can Node.js be used without enabling in the panel?
Yes. You can create a Node.js app and deploy it manually. However, this can be a lot of work. Deploying your Node.js app with Passenger is much easier and recommended.
If you chose to not use Passenger, you would need to find a way to manually deploy your application.
What does the panel checkbox do?
When you enable the checkbox feature in the panel, Passenger knows your website is set up to run a Node.js app and automatically deploys it using Passenger.
For example, if you have the following setup:
app directory: example.com/app.js web directory: example.com/public
Passenger will automatically load the app.js file in the application directory (if you've already started your Node server). So if you visit example.com, it would load the app.js file.
Additionally, when you enable the checkbox, Passenger runs your Node.js files using the system version at:
[server]$ which node /usr/bin/node
If you installed a custom version, Node.js automatically writes lines to your user's .bashrc file. Those lines change the version to your locally installed version. For example:
[server]$ which node /home/exampleuser/.nvm/versions/node/v6.10.0/bin/node
Enabling Node.js in the panel
To enable Node.js:
- Navigate to the (Panel > 'Domains' > 'Manage Domains') page.
- Click the Edit button to the right of your domain under the 'Web Hosting' column.
- The 'Manage Domains' settings page opens:
- Scroll down to the 'Web Options' section and check the 'Passenger (Ruby/NodeJS/Python apps only):' check box.
- Checking this displays a pop-up warning.
If you already have a /public directory in the current 'Web directory, clicking OK will only switch the 'Web directory' to this new /public folder. Nothing in it is removed.
If you do not already have a /public directory, the panel creates it for you with a coming soon page. The files in your current 'Web directory' remain untouched.
- Click OK.
- Your 'Web directory' field automatically adds a /public folder to the end. The NodeJS check box also appears:
- Check the 'NodeJS:' check box to allow Node.js to use Passenger on your domain.