How To Setup Node.js App in cPanel Christopher MaioranaUpdated on November 29, 2023 2 Minute Read Node.js is a popular, event-driven JavaScript runtime you can use to build robust web applications. If you are already familiar with creating Node.js apps, you may be wondering how to get your app onto a shared server, a hosting environment in which you are limited in customization. Node.js requires some configuration of your server environment. But now, you can use a virtual environment within your shared hosting environment that allows for the customization necessary to run your app. Learn how to set up a Node.js in cPanel below. Setup Node.js App in cPanel Enter The Virtual Environment Command Line Stopping and Restarting Your App Note: The Setup Node.js tool is only available on Nginx shared server plans. Setup Node.js App in cPanel Log into cPanel. Choose Setup Node.js App under Software. Click Create Application. Fill in the Application root field (this is the directory in which you will upload for application files). Select your Application URL and startup file (if you do not name a startup file, app.js is used as the default). Fill in the remaining fields with your preferred values. Click Create when ready. Enter The Virtual Environment Command Line If necessary, you have the option of logging into your server via SSH and administering the app on the command line. For some users, it is considered preferable or faster to do some administrative work on the command line. With this cPanel feature, you can easily access the command line for your app and work in a safe, virtual environment. Copy the “source” command listed above your app settings: Once you have logged into the server via SSH, copy and paste the “source” command into the command prompt and hit ENTER. You will then see that you have been logged into your Node virtual environment, seeing a command prompt similar to the following: [example-node-root (10)] [userna5@server-hostname example-node-root]$ Stopping and Restarting Your App You can also stop and restart your app whenever you may need it. This can be done easily from the cPanel interface. Log into cPanel (as you did above). Choose Setup Node.js App under Software. Select your app from the list of existing applications. Click to stop, restart, or edit your application under the Actions table. Well done! You now know how to set up a Node.js app in your cPanel. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles How to Manage AutoSSL Certificates in cPanel How to Migrate Your Website Using cPanel How to Setup an Email Forwarder in cPanel & Webmail How to Create an Email Account in cPanel An Introduction to Branding cPanel for Your Users How to Modify MX Records Using cPanel Setting Domain MX Records to Remote Settings in cPanel Engrampa Archive Manager for Linux How to Create a New cPanel in your Reseller WHM How to Upload a File With cPanel File Manager
I filled in the Nodejs app creation form as indicated, ran the npm install, got the green success msg. But when I try to browse to the app it returns the classic error “Cannot GET /” Specifically, my app is named “lodge”, the url is geekazon.com/lodge and the root path is geekazon.com/lodge. The app files are definitely in that folder. The app.js file contains an app.get route that sends out file index.html. Browsing to geekazon.com/lodge gives the error “Cannot GET /lodge”. Attempting to browse to various other valid routes gives the same error. The passenger.log file contains a normal startup message and no errors. On my localhost this app runs fine and is able to access a MySQL database on InMotion. So I don’t think the problem is in the app itself, it has to be something in the InMotion deployment. Does anybody have any suggestions?