Node.js is a powerful runtime for building server-side applications using JavaScript. In this tutorial, we’ll walk through the process of setting up and deploying Node.js on cPanel.
1. Step 1: Access cPanel
- Log in to your cPanel account.
- Navigate to the “Software” or “Software and Services” section.
2. Step 2: Locate Node.js Version Manager (nvm) or Install Node.js
- If nvm is Available:
- Check if nvm (Node Version Manager) is available in cPanel.
- If yes, use nvm to install and manage Node.js versions.
- If nvm is Not Available:
- In the cPanel dashboard, find the “Software” section.
- Look for the “Setup Node.js App” or similar option.
- Use the provided interface to install Node.js. Choose the version you want.
3. Step 3: Configure Node.js App
- In cPanel, locate the “Setup Node.js App” or “Node.js Selector” section.
- Create a new application and specify the Node.js version.
- Set the application root (your project directory).
- Configure startup file (e.g.,
app.js
orserver.js
). - Save your configuration.
4. Step 4: Deploy Your Node.js App
- Upload your Node.js app files to the specified application root.
- If using Git for deployment, ensure your project is committed and pushed.
- Optionally, set up webhooks for automated deployments.
- Check the logs for any deployment errors.
5. Step 5: Configure Domain and SSL (if needed)
- Navigate to the “Domains” section in cPanel.
- Add or configure your domain/subdomain.
- Enable SSL if needed; some cPanel installations come with AutoSSL.
6. Step 6: Start Your Node.js App
- Return to the “Setup Node.js App” section in cPanel.
- Find your application and click “Run NPM Install” to install dependencies.
- Click “Run Node.js” to start your Node.js app.
7. Step 7: Access Your Node.js App
- Visit your domain/subdomain in a web browser.
- Ensure your Node.js app is running without errors.
- Troubleshoot any issues by checking logs in the cPanel interface.
8. Conclusion
Congratulations! You’ve successfully set up and deployed a Node.js app on cPanel. Keep this tutorial handy for future reference and share it with others looking to harness the power of Node.js on cPanel. Happy coding!