Articles in this section

How to run a simple node.js application in Plesk to test it working?

kb: how-to Plesk Obsidian ABT: Group B Ideal

Applicable to:

  • Plesk Obsidian

Question

How to run a simple node.js application in Plesk to test it working?

Answer

  1. Log into Plesk.

  2. Go to Domains > example.com > File Manager.

  3. Create a file app.js in httpdocs directory and remove index.html file:

    Screenshot.png

  4. Click on the file app.js in File Manager to open it in built-in text editor and put the code below:

    CONFIG_TEXT: const http = require('http');

    http.createServer(function(request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end("Hello, World!\n");
    }).listen(process.env.PORT);

    console.log('App is running...');

  5. Go to Domains > example.com > Node.js and make sure that Document Root and Application Root point to httpdocs directory where app.js file stored

  6. Enable Node.js:

    Screenshot_1_.png

  7. Open in a browser the http://example.com page to see how is it working:

    CONFIG_TEXT: Hello, World!

Was this article helpful?

Comments

4 comments
Date Votes
  • I did this but nothing changed on my url. It still shows the index.html even though I deleted it…. When I click ‘Enable Node.js’, nothing happens. It worked in one of my domains but not the other two. 

    1
  • @David Please create a technical support ticket, the issue needs investigation

    0
  • so inside my env shud i spacify the port or what if somoe is ther plis help me thes is my email pliss contact me i am stack 
    even tho you see thes email latly dont be shay to contact 

    emails : abrehamye60@gmail.com

     

    0
  • Abreham, I don't specify a port in my .env. I'm not sure if that is supported or not. It uses port 3001 by default I guess.

    0

Please sign in to leave a comment.