4

I have installed a popular control panel service called VestaCP (https://vestacp.com/) for my remote linux server. By default it installed both apache and nginx, but despite my best efforts I still can't work out why I need both. I'm familiar with apache and how to configure it, but I've never used nginx before. It appears to be a faster, slimmer apache. Why would you want both? Why not opt for a single one? In the VstaCP settings, it appears I can activate/deactivate Nginx (Proxy Support NGINX) for a website, but I can't use Nginx on its own without apache.

I've found I have an apache conf and an nginx conf that are very similar (differently written, but the logic is identical). I'm not sure, but it suggests only one is actually listened to, not sure which though.

I'm confused. Help.

hedgehog90
  • 1,402
  • 19
  • 37

1 Answers1

3

Nginx is faster and lighter, but many people find it easier to work with Apache because of .htaccess support (Nginx does not have an analog due to performance concern).

The typical scheme is following: you bind Nginx on port 80, configure it to serve static files (jpg, png, js, css, ttf, etc.), and make it proxy to Apache on, say, port 8080 for non-static resources. Apache in turn has abovementioned .htaccess support which allows you to apply rewrite rules and other stuff without webserver reload.

Oleg
  • 22,300
  • 9
  • 68
  • 84
  • Agreed its lighter on memory, but there are a lot of cases where pre-fork Apache is faster, there are also scheduling issues running an event based server on the same instance as a multi-threaded server. – symcbean Sep 14 '15 at 22:04
  • I agreed that there might be cases where Nginx is not a winner (I should learn this question in more details), but benchmarks I found ([this](http://blog.litespeedtech.com/2013/11/12/new-benchmarks-litespeed-vs-apache-vs-nginx-for-static-content/) and [this](https://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/)) tell that Nginx is really faster when serving static content. Probably this is why Nginx is sometimes used in the scheme is described in my answer. – Oleg Sep 15 '15 at 06:15
  • I want to add that I also don't like the idea of using two webservers. In the past we had used the combination of these two, but then we moved to Nginx only (with PHP-FPM) – Oleg Sep 15 '15 at 08:19
  • I also agree with @Curious, probably it is a reverse proxy for Apache HTTPD. – mergenchik Sep 22 '15 at 04:38