Complete Beginner's Guide to Hosting Node.js on Plesk
Nov 13, 2024
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?
Why use Plesk to host?
- 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.