PHP, Node.js & Python Configuration

Hosting Playbook Node/Express API under Apache + Passenger (DirectAdmin)

By the Domain India teamPublished 7 min read
Knowledge base article
Contents (9 sections)

You can run a Node.js and Express API on Domain India DirectAdmin shared hosting. The server's Node.js selector starts your app with Phusion Passenger behind Apache and connects it to your domain, so you don't manage ports, process managers or a proxy yourself. This page is the DirectAdmin checklist for an Express API: layout, database, secrets, SSL, logs and backups.

For the full step-by-step guide

Creating the app, every form field and general troubleshooting are covered in how to deploy a Node.js app on shared hosting. This page adds what is specific to an Express API on DirectAdmin.

Key takeaways

Create the app with DirectAdmin's Node.js selector, choose Node.js 22 or 24, keep the code in a folder outside public_html, and make Express listen on process.env.PORT. Put secrets in the app's environment variables, connect to MySQL on localhost, and restart the app from the panel after every change. Shared hosting suits small APIs; for a production API with steady traffic, use the App Platform or a VPS.

1. What our DirectAdmin server provides

ItemOn Domain India DirectAdmin (measured September 2026)
Node.js versions14, 16, 18, 19, 20, 22 and 24 via the Node.js selector
How the app runsPhusion Passenger behind Apache; no public port of your own
SSHJailed shell, off by default; ask support. Key login only
File transferFTP with TLS, logins in the form name@domain; SFTP once SSH is enabled
Scheduled jobsCron; the shortest effective interval is 4 minutes
Outgoing mail1,000 messages per day per account
BackupsJetBackup 5, weekly on Sunday, last 5 copies kept

Node.js 20 and older are end of life, so choose 22 or 24 unless your code needs something else.

2. Lay out the app

Keep application code out of the public web folder:

text
/home/USERNAME/
  domains/example.com/public_html/    # static files or a PHP site, if any
  api/                                # your Express app (the application root)
    app.js
    package.json
    routes/

In the Node.js selector, set the application root to api, the application URL to the domain or a path such as example.com/api, and the startup file to app.js. The selector writes the Passenger configuration for you; you don't need your own entry file in public_html.

3. The Express start file

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

app.use(express.json());

app.get('/health', (req, res) => res.json({ status: 'ok' }));
app.use('/items', require('./routes/items'));

app.use((req, res) => res.status(404).json({ error: 'Not found' }));
app.use((err, req, res, next) => {
  console.error(err);
  res.status(500).json({ error: 'Internal Server Error' });
});

app.listen(process.env.PORT || 3000);

Passenger tells the app which port to use, so never hard-code one. If the application URL is a sub-path such as /api, your routes may need to include that prefix; call /health under the full URL after the first start to check.

4. Deploy and update

  1. Build locally.
    Run TypeScript or bundler builds on your computer or in CI and upload the output.
  2. Upload the code
    to the application root with FTP or the DirectAdmin File Manager, including package.json and your lock file, without node_modules.
  3. Install dependencies
    with the selector's Run NPM Install button, or with npm ci --omit=dev over jailed SSH if it is enabled.
  4. Restart the app
    from the Node.js selector and call /health to confirm.

For a rollback, keep the previous release as a Git tag or an archive on your computer, upload it again, and restart. git pulls are possible over jailed SSH when git is available in your account; see deploying with Git.

5. Database and secrets

Create the database and user under Account Manager › Databases in DirectAdmin; see creating and connecting to a MySQL database in DirectAdmin. Connect with a pool:

javascript
const mysql = require('mysql2/promise');

module.exports = mysql.createPool({
  host: 'localhost',
  user: process.env.DB_USER,
  password: process.env.DB_PASS,
  database: process.env.DB_NAME,
  connectionLimit: 5,
  enableKeepAlive: true,
});

Put DB_USER, DB_PASS, DB_NAME and API keys in the environment variables section of the selector, then restart. Don't commit them to Git, and never put a .env file inside public_html. Keep the pool small: every connection counts against your account's limits.

MySQL port 3306 is closed from outside. To reach the database from your computer, use an SSH tunnel once SSH is enabled; see how to connect to the MySQL database.

6. SSL, logs and backups

  • HTTPS. Issue a free Let's Encrypt certificate in DirectAdmin and turn on the HTTPS redirect; see Let's Encrypt in DirectAdmin.
  • Logs. Your app's console output goes to the log named on its selector page. The domain's web server logs can be viewed in DirectAdmin, and older logs are archived as .tar.gz files under domains/example.com/logs. See reviewing error logs.
  • Backups. JetBackup 5 takes a weekly backup every Sunday and keeps the last 5 copies. Keep your own copies too: your code in Git, and regular database exports downloaded off the server.

7. Common errors

What you seeLikely causeFix
503 or "error starting web application"The app crashed at startupRead the app log, check the startup file name, restart
404 on every API routeRoutes don't match the application URL pathCheck the path prefix and test /health
ER_ACCESS_DENIED_ERRORWrong database user, password or privilegesReset them under Account Manager › Databases and update the environment variables
Changes don't appearApp not restartedRestart from the Node.js selector
Calls to an outside service time outOutbound connections on unusual ports are filteredTest the port first; use a VPS or the App Platform if it is blocked

8. When to move off shared hosting

Shared hosting runs your API to answer web requests within the account's CPU and memory limits. It isn't for background workers, queues or long-lived connections. The App Platform builds Node.js apps automatically, deploys from GitHub or a deploy token, and includes PostgreSQL and SSL; it does not support WebSockets. A VPS gives you root access for anything else.

DA Starter
₹100/mo + GST
  • 10 GB NVMe SSD Storage
  • 50 GB Monthly Bandwidth
  • 1 Website
  • 5 Email Accounts
See plan details
App Starter
₹100/mo + GST
  • 512 MB RAM per app
  • 1 vCPU
  • 5 GB NVMe SSD
  • PostgreSQL Database
See plan details

Prices on the cards are live Domain India list prices and exclude 18% GST.

Frequently asked questions

Can I run an Express API on Domain India DirectAdmin hosting?

Yes. DirectAdmin's Node.js selector runs your app with Phusion Passenger behind Apache. Create the app, upload your code, install dependencies and start it from the panel.

Which port should my Express app listen on?

Use process.env.PORT. Passenger assigns the port and routes traffic to your app, so a fixed port will not work.

Do I need an app.js file in public_html for Passenger?

No. The Node.js selector writes the Passenger configuration from the application root and startup file you enter. Keep your code outside public_html.

Is SSH included for deploying my API?

Jailed SSH access is available on every shared hosting plan. It is off by default; ask support to enable it. Login is by SSH key only. You can deploy without SSH using the panel.

How do I restart my Node.js app on DirectAdmin?

Use the restart button for the app in the Node.js selector. Restart after every code change or change to environment variables.

Can my API use WebSockets or background workers?

Not reliably on shared hosting, and the App Platform does not support WebSockets. For WebSockets or long-running workers, use a VPS.

Ready to deploy? Follow the full Node.js deployment guide, compare App Platform plans, or open a support ticket to have jailed SSH enabled.

Run your API on the App Platform

Deploy from GitHub or with a deploy token, with automatic Node.js builds and free SSL.

See App Platform plans

Ready when you are

Get DirectAdmin hosting from ₹100/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Node/Express API on DirectAdmin with Passenger