F
F
frontendo2017-08-06 13:53:21
Node.js
frontendo, 2017-08-06 13:53:21

How to properly set up virtualbox + nodejs local development environment?

I decided to try the capabilities of nodejs, but in order not to use it from under Windows, I installed it on virtualbox centos7, connected to the guest OS via ssh 192.168.137.125:22, installed nodejs, initialized the project folder, wrote the code from the tutorial into the file

var http = require('http');

var server = http.createServer(function(req, res) {
res.writeHead(200, {"Content-Type": "text/html"});
res.write('<!DOCTYPE html>'+
'<html>'+
' <head>'+
' <meta charset="utf-8" />'+
' <title>My Node.js page!</title>'+
' </head>'+ 
' <body>'+
' <p>Here is a paragraph of <strong>HTML</strong>!</p>'+
' </body>'+
'</html>');
res.end();
});
server.listen(8080);

console.log(server);

I launched the node index.js file, I didn’t get any errors. I
try to go to the main OS browser at 192.168.137.125:8080, but I get an endless page load and a connection timeout crash. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Volintsev, 2017-08-06
@frontendo

https://stackoverflow.com/a/13752409/3544196
Need to "dig a hole" in the firewall
Save config
Restart iptables
Now try to open your project in a browser

A
Alexander Talalaev, 2017-08-06
@neuotq

Vagrant is suitable for local development , after installation you select the appropriate box and go ahead. It greatly simplifies the work with a virtual machine and is optimized specifically for creating and managing a local infrastructure environment for the developer.
Alternatively, you can use Docker, where the approach is completely different, but there is a little more manipulation during development. But for installation on a server, just the same, Docker with its concept (one process per service / server, painless software upgrade, etc.) is much better suited.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question