$sudo apt-get install apache2

$Sudo apt-get install nginx

Both installed but only apache is running and if we go for nginx after stopping service of apache ,nginx service is running but not showing its default page!! Please help to resolve

  • You can't listen to same port with two different web servers. – Gen May 3 '16 at 6:10

You can't listen to same port with two servers but if you want you can configure Nginx as a reverse proxy for apache. Here is a great tutorial to do that https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-reverse-proxy-for-apache. You can also check this one http://kbeezie.com/apache-with-nginx/ .

Hope this might help you.


As it has already been stated above, it is impossible to run different services on the same port as only one service can run on a port at a time. You can however run Nginx as a proxy server (each one running on a different port).

Note: you can configure each server's document root to load different home pages when both are running on different port (if that is what you want).

  • The question is about how both apache and nginx would work at the same time while both are listening to the same port. I put localhost in the browser. How would they mange to serve at the same time? I think you are not addressing the problem – Mostafa Ahangarha Apr 22 '17 at 9:25
  • i was trying to provide alternative means of achieving the aim of the question, however my answer has been edited to reveal that. – bamobravo Apr 20 '18 at 16:17

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.