Yazı Boyutu:

cPanel is a modern hosting panel that supports not only PHP projects but also Node.js applications. Deploying Node.js-powered web apps via cPanel is relatively simple. In this guide, we’ll walk you through step-by-step instructions on how to set up, publish, and optimize your Node.js application using cPanel.

If you need hosting packages with Node.js support, check out our Node.js Hosting options.



1. Purchase a Hosting Plan that Supports Node.js You’ll need a shared hosting package that includes Node.js support. Visit the link below to explore supported hosting options and activate instantly: https://www.ekasunucu.com/paylasimli-hosting


2. Log into cPanel and Open the "Setup Node.js App" Section

Once you’re in cPanel, scroll to the Software section and click on "Setup Node.js App". This is where you’ll manage all your Node.js applications.


3. Create a New Node.js Application

Click the "Create Application" button, and you’ll see the following form:

  • Node.js version: Choose the latest version, e.g., 18.18.2 (recommended)

  • Application mode: Development or Production (for live deployment use Production)

  • Application root: Full path where your project is located (e.g., /home/username/public_html/nodejs-projem)

  • Application URL: Select your domain name (e.g., ekasunucu.org)

  • Application startup file: server.js or app.js (your main app entry point)


4. Upload Your Project Files

Use the File Manager or FTP to upload your Node.js app files to the public_html/nodejs-projem folder. Ensure that files like package.json, server.js, and node_modules are present.

Note: If node_modules wasn’t uploaded, use terminal or SSH to run npm install.


5. Run and Test the Application

After saving the settings, your app will appear in the "Web Applications" list. From here, you can run the "Run NPM Install" command, check logs, and restart the application.

 


6. Common Errors and Solutions

  • Empty application root field: Make sure to enter the full directory path (e.g., /home/username/public_html/folder)

  • 404 Error: Your server.js or app.js must listen to the port defined by process.env.PORT

app.listen(process.env.PORT || 3000, () => {
    console.log("Server is running");
});

Conclusion: cPanel offers a user-friendly interface for deploying Node.js apps. By following the steps above, you can easily get your project online.

Looking for Node.js-ready hosting? Check out: Node.js Hosting Plans