Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache needed for NodeJs?

On my local machine I have set up a web project like toled in a tutorial. I have installed XAMPP and used MySQL and Apache to run my Node.JS backend. Now I'm about to use a external server to host the project and make it available through the internet.

So I have to setup the server and I want to know why I need Apache (from XAMPP) to run the Node.JS backend? I thought the node.js is a web server by itself? So would it be a clever idea to set up the external server again with XAMPP?

When I want to start index.html by the URL could I also do this with the node.js?

like image 302
WeSt Avatar asked Oct 05 '17 06:10

WeSt


People also ask

Do I need Apache with node js?

Node. js provides capabilities to create your own web server which will handle HTTP requests asynchronously. You can use IIS or Apache to run Node. js web application but it is recommended to use Node.

Does Apache work with node js?

In this article, we'll examine some of the benefits that Apache brings to Node. js applications. We'll also walk through a tutorial with a working code sample to demonstrate how to configure Apache for a Node application.

Does Nodejs replace Apache?

If you're prepared to re-write your PHP in JavaScript, then yes, Node. js can replace your Apache. If you place an Apache or NGINX instance running in reverse-proxy mode between your servers and your clients, you could handle some requests in JavaScript on Node.

Does Nodejs need web server?

Node. js will handle HTTP traffic very well with it's core module, http. But it will be significantly slower with HTTPS. So that's one reason to put it behind a proxy server, as software like nginx or Apache will handle SSL much faster, and then just let the raw request be handled by node.


1 Answers

No you won't need an Apache server. Because Node itself will serve as a Server Especially if you are working with Frameworks like Express.

You don't need Nginx or Apache at all, but you can use if you want. It's very cosy to some people use Nginx to do the load balance, or even other stuff like handle the https or server static content. It's your choice at the end.

For best performance, though, you'll combine node.js with nginx, depending on the needs of your application. nginx does a better job of serving static files, though at the highest performance for static files will come from using a CDN. Most often, you'll use nginx as a reverse proxy: the web request will be received by nginx, which acts as a load balancer in front of several identical or subdivided servers. If it needs to server static files as well, it will just answer those requests directly.

like image 108
Sagar Avatar answered Sep 27 '22 22:09

Sagar