Apache and Nginx both on port 80 [closed] Apache and Nginx both on port 80 [closed] nginx nginx

Apache and Nginx both on port 80 [closed]


I'm not quite sure what your hosting company means by their comment but you won't be able to run BOTH Apache and Nginx on port 80. Once one is bound to port 80 the other will be unable to bind to it.

Probably the best configuration in your current situation would be to put Nginx on port 80 and Apache on 8000 or similar.

Use nginx to serve static files (see try_files because "if" is evil) and then proxy all requests for PHP to port 8000 using the HTTP proxy module.

The other common configuration for PHP with Nginx is to use PHP-FPM and proxy via FastCGI, just google "PHP-FPM Nginx {Your OS} tutorial" for a tutorial.

There much debate about the performance of PHP-FPM/mod_php but in my personal experience I have found PHP-FPM more performant.


I would use nginx as the web facing server on port 80 and proxy pass to apache which would be running on a different port. Many sites run this configuration. Serving static files with nginx is much more efficient than with apache. It is actually a lot simpler than it may sound.

This document explains in detail.


You should bind your externally facing webserver to the public IP address and the internally facing webserver to localhost (127.0.0.1:80).

So if you are using Nginx publicly then bind that to the public IP address and have it proxy to Apache at localhost.

Its better to use separate ports to make it easier to debug.