Wayne Ashley Berry
Wayne Ashley Berry

Reputation: 539

Node equivalent to index.html

I'm coming from a LAMP background and want to test out node for production.

What seems a little confusing to me is that in Apache url's map to folders, and the server will automatically look for an index.html or index.php if you aren't re-writing urls.

What would the equivalent be in node?

I'm thinking it'd be something like checking the request url and matching it, then loading a specific node module which runs the app.

This might seems simple for a single app, but we run tons of client apps on our server so i'm used to having different frameworks in different folders and index.php just runs it.


to be more specific. i'm currently running a few codeigniter and wordpress installations on our server. so i'd want to run a few node apps/frameworkds in different 'subfolders'

Upvotes: 0

Views: 375

Answers (1)

Mauvis Ledford
Mauvis Ledford

Reputation: 42374

With Node you don't really use Apache. It's similar to Ruby in that is runs its own web server.

However, you can probably get Apache to run Node files using mod_node. As far as I know this is non-standard though and you definitely lose the "non-blocking" advantages of Node. But for experimenting (and not load testing) it's fine.

Check out Express if you're looking for an MVC architecture written in Node.

If you're just looking to run the most basic sample web server, just run the example hosted on the main page: http://nodejs.org/

Lastly, I had that same issue you are experiencing where I have one box hosting a lost of stuff and Apache taking up port 80. The answer here is to use a reverse proxy like Nginx to run on port 80 and redirect traffic to Apache / Node / Ruby / etc. Best of both worlds and since Nginx is written non-blocking you still gain the benefits of node.

I actually wrote an in-depth blog article about this a few months ago: http://readystate4.com/2011/07/15/nginx-apache-and-node-all-living-harmony/

Upvotes: 1

Related Questions