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.js
inhttpdocs
directory and removeindex.html
file: -
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...'); -
Go to Domains > example.com > Node.js and make sure that Document Root and Application Root point to
httpdocs
directory whereapp.js
file stored -
Enable Node.js:
-
Open in a browser the
http://example.com
page to see how is it working:CONFIG_TEXT: Hello, World!
Comments
0 comments
Please sign in to leave a comment.