Complete Beginner's Guide to Hosting Node.js on Plesk

Nov 13, 2024

Complete Beginner's Guide to Hosting Node.js on Plesk

Plesk is the tool of choice if one is just starting with web hosting and wants to run Node.js applications on the server. Basically, Plesk is a control panel that assists in managing websites and web applications. Here, we go through some simple steps on how to host a Node.js application on Plesk for users.

What is Node.js?


Node.js is an extremely popular environment that allows developers to run JavaScript on the server side. This is widely used for creating web applications because it is fast, can scale well, and is ideal for tasks that involve database management or interacting with APIs. But for any application in Node.js to go live on the web, it has to be hosted somewhere, and that's where Plesk comes in.

Why use Plesk to host?


It is known as one of the friendliest control panels out there. It will make your life much easier because it provides a very intuitive way to manage your server. Plesk can also run a number of programming languages, including Node.js. It also offers the tools that can automatically set up and install dependencies required to run an application.

Step-by-Step Guide to Hosting Node.js on Plesk
  • In the Plesk interface
  • Log in to Plesk.
  • Upload the Node.js application files including package.json on the server using the File Manager.
  • Go to Domains > example.com > Create Website > Node.js and set the application configuration:
  • In Plesk for Linux: the Document Root directory must be the subdirectory of the Application Root directory:
  • Click Install
  • Note: the app.js file should be located in Application Root.
  • In Plesk for Windows: the Application Root directory should be the same as the Document Root directory.
  • Click NPM install and Run script if needed.
  • In the command-line interface (Linux only)
  • Connect to the server via SSH.
  • Run npm install "packagename" command to download and install a package from a npmjs.com repository. "packagename" should be replaced with your package name. In the example below, the application blockchain-wallet-service is used.
    export PATH=$PATH:/opt/plesk/node/18/bin

    npm install -g blockchain-wallet-service

    blockchain-wallet-service start --port 3000

Note: instead of the root user, it is better to use one of the system users of subscriptions to run 3rd-party applications in order to avoid possible security issues.

If there is no executable /opt/plesk/node/18/bin/npm, go to the Plesk menu Tools & Settings > Updates and Upgrades > Add/Remove Components and install the components Node.js support.

Troubleshooting Tips

If anything goes wrong, just log in to the Plesk dashboard and have a look at the logs. This will allow you to see what went wrong. Remember that some applications work only on particular versions of Node.js.

Conclusion

Basically, hosting a Node.js application is pretty easy in Plesk, even for a fresher. That's why Plesk has an interface which is easy to work with; it has done many technical steps by default. Go ahead, start hosting your Node.js app with these steps onwards. Happy hosting!

Still not sure ? Contact our IT Consultant to get assistance which web hosting package is best for you or get customized plan. We would be happy to provide assistance finding the right solution for you.