Saturday, February 5, 2022

How To Install NodeJS & Create Test Web Server On Rocky Linux 8

 in This Tutorial you will learn " How To Install NodeJS & Create Test Web Server On Rocky Linux 8"

Node.js is a cross-platform JavaScript runtime environment built on Chrome’s JavaScript designed to execute JavaScript code on the server-side. With Node.js, you can build scalable network applications.
Homepage - https://nodejs.org/en/
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf module enable nodejs:14 -y ; dnf install nodejs npm -y

Create Test Web Server -
nano web_server.js
const http = require('http');
const port = 9000;
const server = http.createServer((req, res) => {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World\n');
});
server.listen(port, () => {
  console.log(`Server running at http://192.168.1.60:${port}/`);
});

firewall-cmd --permanent --add-port=9000/tcp ; firewall-cmd --reload
node --inspect web_server.js
_________________________________________________________________________________________


No comments:

Post a Comment