Run Node.js on DirectAdmin Hosting with Phusion Passenger

Can You Run Node.js on Shared Hosting?

The short answer is yes — provided your hosting provider has Phusion Passenger installed. Phusion Passenger is an application server that integrates with Apache (used by DirectAdmin) and can run Node.js, Python, and Ruby applications directly, without requiring a separate process manager.

AsiaGB Hosting supports Phusion Passenger on all DirectAdmin plans, which means you can deploy a Node.js application such as Express.js on shared hosting without needing a VPS.

Before You Start

Shared hosting is ideal for small to medium Node.js apps such as REST APIs, backend services, or Express.js apps with moderate traffic. For high-traffic production workloads or Next.js SSR, consider an AsiaGB VPS starting at 500 THB/month.

What Is Phusion Passenger?

Phusion Passenger (commonly called "Passenger") is a web application server that integrates directly with Apache or Nginx. It acts as the bridge between the web server and your Node.js application.

Instead of manually:

Passenger handles all of this automatically. When an HTTP request arrives, Passenger starts the Node.js process, forwards the request, and automatically restarts the process if it crashes.

Prerequisites

Step-by-Step Setup on DirectAdmin

1. Create a Domain or Subdomain in DirectAdmin

Log in to DirectAdmin → Domain Setup → add a subdomain such as api.yourdomain.com specifically for your Node.js app. If you want to run it on the root domain, use public_html directly.

2. Upload Files to the Document Root

Upload all Node.js project files to the document root of that domain, for example /home/username/domains/api.yourdomain.com/public_html/. You can use SFTP or FileZilla.

3. Create .htaccess to Enable Phusion Passenger

Create a .htaccess file in the document root with the following content:

PassengerEnabled on
PassengerNodejs /usr/bin/node
PassengerStartupFile app.js
PassengerAppType node

Change app.js to match your actual entry point file (could be server.js, index.js, etc.).

4. Verify Apache Has the Passenger Module

If Phusion Passenger is already installed on your hosting, the .htaccess above is sufficient. If the app does not work, contact your hosting support to enable Passenger on your account.

Configuring package.json and app.js

Sample package.json for an Express.js app:

{
  "name": "my-api",
  "version": "1.0.0",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "^4.18.2"
  }
}

And a basic app.js:

const express = require('express');
const app = express();

app.use(express.json());

app.get('/', (req, res) => {
  res.json({ message: 'Hello from Node.js on Hosting!' });
});

app.get('/api/status', (req, res) => {
  res.json({ status: 'ok', timestamp: new Date().toISOString() });
});

// Phusion Passenger provides the port via the PORT environment variable
const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});
Important: Use process.env.PORT

Phusion Passenger automatically assigns a port via the PORT environment variable. Never hard-code a port number such as app.listen(3000). Always use process.env.PORT || 3000.

Running npm install via SSH

After uploading your files, connect via SSH to install dependencies:

# SSH into your hosting
ssh [email protected]

# Navigate to your project directory
cd ~/domains/api.yourdomain.com/public_html/

# Install production dependencies
npm install --production

# Verify node_modules was created
ls -la node_modules/ | head -10

Once npm install completes, Phusion Passenger will detect the changes and restart the app automatically. Test by visiting the domain URL in your browser.

Manually Restarting the App

To force-restart the app after code changes, touch the tmp/restart.txt file:

mkdir -p tmp
touch tmp/restart.txt

Passenger detects this file and restarts the Node.js process automatically.

Hosting vs VPS for Node.js: Comparison

Factor Shared Hosting (DirectAdmin) VPS
Starting price ~199 THB/month ~500 THB/month
Node.js install Phusion Passenger (easy) Self-install via apt/nvm (flexible)
Process manager Passenger handles automatically PM2 / systemd (manual setup)
Node.js version Limited by hosting provider Any version via nvm
RAM Shared with other users Dedicated allocation
Best for Small APIs, test apps, MVPs Production, high traffic
SSH access Yes (restricted permissions) Yes (root access)

Troubleshooting Common Issues

500 Error After Deployment

Common causes: node_modules not installed yet, or the entry file path is wrong. Check:

App Does Not Restart After Code Changes

Passenger caches the binary. Force a restart by running:

touch ~/domains/yourdomain.com/public_html/tmp/restart.txt

npm install Fails Due to Permissions

If you see a permission error, verify your SSH user has write access to that directory, or try:

npm install --prefix ~/.npm-packages

Environment Variables Not Working

On shared hosting, create a .env file in the project root and load it with the dotenv package:

npm install dotenv
# In app.js, first line:
require('dotenv').config();

Frequently Asked Questions

Can I run Node.js on shared DirectAdmin hosting?
Yes, if your hosting provider has Phusion Passenger installed. Passenger is an application server that runs Node.js and Express directly alongside Apache. AsiaGB Hosting supports Passenger on all plans.
What is the difference between Node.js on hosting vs VPS?
On a VPS you install Node.js yourself and use PM2 for process management. On shared hosting, Phusion Passenger handles starting and stopping your app automatically. Shared hosting is simpler but has more restrictions on ports and environment variables.
Where do I place app.js on DirectAdmin hosting?
Upload all files to the document root of your domain, for example public_html. Then create a .htaccess file enabling PassengerEnabled and PassengerStartupFile pointing to your entry file.
Can I run npm install on shared hosting?
Yes, if your hosting plan includes SSH access. Connect via SSH, navigate to your project directory, and run npm install normally. AsiaGB Hosting provides SSH access on all plans.
Which Node.js versions are supported on DirectAdmin hosting?
Most DirectAdmin hosting providers support Node.js 18 LTS and 20 LTS. You can check the installed version via SSH using the node -v command.
Can I use Express.js or Next.js on shared hosting?
Express.js works well on shared hosting via Phusion Passenger. Next.js with Static Export also works. However, Next.js SSR requires port binding that conflicts with shared hosting restrictions; a VPS is recommended for full Next.js SSR.
How do I restart my Node.js app on Phusion Passenger?
Create or touch the file tmp/restart.txt inside your project directory. Phusion Passenger detects this file and automatically restarts the Node.js process.
Summary: Node.js on DirectAdmin Hosting

Shared hosting with Phusion Passenger is a cost-effective option for small Node.js apps and MVPs. If you need to scale or run full Next.js SSR, consider an AsiaGB VPS starting at 500 THB/month with SSD storage and 99% uptime.