Applicable to:
- Plesk Obsidian
Question
How to run a simple node.js application in Plesk to test it working?
Answer
-
Go to Domains > example.com > File Manager.
-
Create a file
app.jsinhttpdocsdirectory and removeindex.htmlfile: -
Click on the file
app.jsin 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...'); -
Go to Domains > example.com > Node.js and make sure that Document Root and Application Root point to
httpdocsdirectory whereapp.jsfile stored -
Enable Node.js:
-
Open in a browser the
http://example.compage to see how is it working:CONFIG_TEXT: Hello, World!
Comments
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.
@David Please create a technical support ticket, the issue needs investigation
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
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.
Please sign in to leave a comment.