As comments have said, nodejs replaces apache. If your nodejs program is called server.js
, you need to run this to get your server up and running. node server
.
If you also have apache running on the same port, nodejs won't start. It will complain that the port is already in use. But you may not see that problem, because the various nodejs sample programs use port numbers like 3000, whereas apache typically uses port 80.
Switching from apache to node involves also switching your way of thinking about how web servers work. apache is a file server with, well, a patch (hence the name), to run php scripts instead of just sending their source. On the other hand, nodejs is a non-file server. If you want it to serve static files you have to build in the "static" middleware code to do that.
At the heart of apache is the idea that http://example.com/a/b/c.html
looks up a file in your server file system at <<root>>/a/b/c.html
. Nodejs is not inherently a file server. In it, /a/b/c.html
is a text string called a route. Only if you bind that route to a file system with "static" middleware (or some other code) does it deliver files from the file system.
Your browser code should work the same. You may have to change your route names in your browser code from whatever.php
to just whatever
, or write your nodejs code to accept the .php
stuff.