Ultra Web Hosting Docs

Node.js & Python Apps

CloudLinux provides application selectors that let you run Node.js and Python applications on your shared hosting account, complete with version management and virtual environments.

Setting Up a Node.js Application

Creating the Application

  1. Log into cPanel.
  2. Scroll to the Software section and click Setup Node.js App.
  3. Click Create Application.
  4. Configure the following settings:
    • Node.js version: Select the version your application requires (e.g., 18, 20, 22).
    • Application mode: Choose Development while testing or Production for a live site.
    • Application root: The directory containing your app files, relative to your home directory (e.g., myapp).
    • Application URL: The domain and path where the app will be accessible (e.g., yourdomain.com).
    • Application startup file: The entry point for your app (e.g., app.js or server.js).
  5. Click Create to set up the application.

Installing Dependencies

After creating your application, you need to install your npm packages:

  1. On the Node.js app page, find your application in the list.
  2. Click the pencil icon to edit the application.
  3. Click Run NPM Install to install all dependencies from your package.json file.
  4. Once the installation completes, click Restart to apply the changes.
Note You can also manage your application from the command line via SSH. When you create an app through the selector, cPanel shows you the command to activate the virtual environment, which sets up the correct Node.js version and PATH for your terminal session.

Environment Variables

To set environment variables for your Node.js app:

  1. Edit your application in the Node.js app selector.
  2. Scroll down to the Environment variables section.
  3. Click Add Variable, enter the name and value, then click Save.
  4. Restart the application for the variables to take effect.

Setting Up a Python Application

Creating the Application

  1. Log into cPanel.
  2. Scroll to the Software section and click Setup Python App.
  3. Click Create Application.
  4. Configure the following settings:
    • Python version: Select the version your application requires (e.g., 3.11, 3.12).
    • Application root: The directory containing your app files (e.g., myflaskapp).
    • Application URL: The domain and path where the app will be accessible.
    • Application startup file: The WSGI entry point (e.g., passenger_wsgi.py).
    • Application Entry point: The WSGI callable in your startup file (e.g., application).
  5. Click Create.

Installing Python Packages

You can install Python packages through the app selector interface or via the command line:

Using the interface:

  1. Edit your Python application.
  2. Scroll to the Configuration files section and add your requirements.txt path.
  3. Click Run Pip Install to install all packages listed in the file.
  4. Restart the application.

Using SSH:

source /home/username/virtualenv/myflaskapp/3.11/bin/activate
pip install flask gunicorn
pip freeze > requirements.txt
Tip Always use a requirements.txt file to track your Python dependencies. This makes it easy to reinstall packages if you need to recreate your application.

Common Application Frameworks

Express.js (Node.js)

A minimal app.js for Express:

const express = require('express');
const app = express();
const port = process.env.PORT || 3000;

app.get('/', (req, res) => {
    res.send('Hello from Express!');
});

app.listen(port, () => {
    console.log(`App listening on port ${port}`);
});

Flask (Python)

A minimal passenger_wsgi.py for Flask:

from flask import Flask

application = Flask(__name__)

@application.route('/')
def hello():
    return 'Hello from Flask!'

Managing and Restarting Apps

You can manage your running applications from the Node.js or Python app selector page in cPanel:

Warning Node.js and Python applications consume entry processes and memory from your hosting account's resource limits. Monitor your resource usage if your application handles significant traffic.