If you’re interested in hostingNode.js apps, we’ve got good news for you. Plesk comes with a Node.js extension that allows you to manage apps easily. In this article, we’ll describe in detail how to work with Node.js apps in the context of Plesk Obsidian, the latest version of Plesk
The first thing you need to do is install Plesk Obsidian. I chose Debian as the server OS for this article. You can use either a Linux distro or Windows – just note that there could be some minor differences if you go with a different OS. Assuming Plesk is already installed, let’s install the Node.js extension.
Log in to Plesk, go to “Tools and Settings”, and click “Updates and Upgrades”. Next, go to “Add/Remove Components”. Find the “NodeJS support” component. Select it, and continue with the Node.JS installation. In a few minutes, all the necessary components will be installed and you’ll be ready to go!
To make sure everything works, let’s try to host a sample Node.js app, such as a “Hello, World” app. You can download one here. Copy/pasting the contents of the app.js file manually is an option. But I suggest trying out another Plesk extension instead – namely, the Git extension.
First, you have to create a subscription (a domain with hosting). Then, you need to create a target directory where the app will be stored. Select your subscription, go to the “Files” tab, and create a directory named “hello-world”. Next, go to the “Domains” tab, choose the website, and click the “Git” button.
Now, you’ll learn how to set up a local repo as a mirror of a remote one, and deploy the code to the previously created directory. Set this URL as the remote Git repo URL, and change the target to the “hello-world” directory. The settings should look like this:
The next step is to change the “Document root” for the domain. Notice that I’ll be talking about “Document root” and “Application root”: they aren’t one and the same. When we’re talking about web apps (e.g. Node.js based apps or similar), the “Document root” is the location where the static assets can be found. Meanwhile, the “Application root” is the root directory where the app itself is located. In most cases, the “Document root” is a directory inside the “Application root” directory (e.g. “public”).
You need to change the document root now. To do so, go to “Domains”, select your website and go to “Hosting Settings”:
Change the existing document root to ‘hello-world/public’ (without quotes) and click the ‘Ok’ button to save the changes.
#product and technology #node.js #plesk