Podcast | How to Host Node.js Applications on Plesk Obsidian

To make sure everything works, you can try to host a sample Node.js app, such as a “Hello, World” app. You can find one from Github in the notes of this episode. 

Copy/pasting content from the App.js file manually is an option. However there’s another Plesk extension instead worth exploring — the Git extension. 

Now, to use the Git extension, you have to create a domain with hosting, which is called a subscription. Then, you need to simply create a target directory where the app will be stored. From there, you’ll be able to install the Git extension. Then you need to set up a local repo to pull the code from. You’ll want the local repo to mirror the remote one so the code can be deployed correctly. 

Again, see our tutorial for step-by-step actions with screenshots.

Differences Between ‘Document Root’ and ‘Application Root’

As you set up your application, you’ll see references to both “Document root” and “Application root.” It is important to note that they are not always the same thing. 

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…this is likely your HTML, CSS, and image files.

The “Application root” is the root directory where the app itself is located. This, for the purpose of this episode, is where the executable Node.js code lives. 

In most cases, the “Document root” is a directory inside the “Application root” directory.

You can change the Document root in Plesk by going to “Domains”, selecting your website and going to “Hosting Settings.”

From there you can change the existing Document root to match the repo name, and adding “slash public” to the end — but again, note that your milage may vary depending on your own server environment and code repo.

Enable Node.js Support

The last thing to do before you run an app is to enable Node.js support on the domain. Go to “Domains”, choose the website and click “Node.js”. Here you will see some information about your app with a row of buttons on top. Click “Enable Node.js”, and in a few seconds, you’ll see a confirmation screen.

You will then want to visit the “Application URL” to make sure that the app is running. If you see the expected results (in the example mentioned, “Hello World” will show on the screen), you’ve successfully installed and enabled Node.js.