Also, should I stop using LAMP stack for my small and experimental PHP websites that very few people visit, or is it good enough?
Also, should I stop using LAMP stack for my small and experimental PHP websites that very few people visit, or is it good enough?
Apache, by contrast, approaches large numbers of requests by spinning off more processes to handle them, typically consuming a lot of RAM as it does so. Apache looks at the elephant and thinks about how big it is as it tucks into its meal, and sometimes Apache gets a little anxious about the size of its repast. Nginx, on the other hand, just starts chomping.
The difference is summed up succinctly in a quote by Chris Lea on the Why Use Nginx? page: "Apache is like Microsoft Word, it has a million options but you only need six. Nginx does those six things, and it does five of them 50 times faster than Apache."
Source: http://arstechnica.com/business/2011/11/a-faster-web-server-...
Chris Lea
Also, I can't imagine anyone running NGINX without having access to the config file.
However since using nginx I have done away with caching as it is so much faster than apache + caching that I don't really need it.
You configure WPS to spit out gzipped copies of each page on disk, then you configure nginx to serve gzipped pages directly whenever they are found (gzip_static and try_files).
Basically you can serve compressed pages straight off disk. And thanks to the miracle of operating system file caching, it's usually straight from memory.
It's plenty good enough; it's worked for decades already. If it ain't broke don't fix it. If traffic on a site is ramping up to the point where you're thinking "I might need to get new hardware for this soon", that's the time to start looking at a higher-performance webserver.
And honestly I'd look at moving away from PHP more urgently than moving away from Apache, if only because of their respective security records.
In my opinion, this is like moving away from C due to its security record.
And with NGINX I understand _every_ line in the configuration files, with Apache it was almost like configuring by coincidence.
Just my opinion.
For larger scale deployments, nginx is generally considered to perform better than apache.
There is the ability to use Lua with MySQL, PostgreSQL, MemCache, Redis, Upstream etc to perform functions of an app server e.g. authenticate users, serve JSON from a database. It's fast and keeps your app layer focused on real business logic.
If you already have Apache, don't bother switching. If you're starting new, use Nginx.
With modphp in limited memory environments you run into memory swap issues super fast unless you are careful about your Apache configs, since it will, in most default environments, spawn many more Apache processes than you have memory for. PHP makes the Apache process use 20-200M of memory for many standard apps like drupal or wordpress. Put it on a 1Gig linode without turning down the MaxClients and add 10 concurrent users and you will see the site grind to a halt. Now install nginx and php-fpm and follow anyone's basic how-to, it will only spawn as many php processes as your memory and cpu cores can handle, and nginx will keep spinning out the static files while php is churning in the background, living within reasonable memory bounds.
You can achieve the same thing in Apache, but I never really knew how to do that until Nginx taught me. I have never seen Apache set up right for this in any of my clients' existing servers and they can never scale at all.
Modphp is a bit faster if you have enough memory for your PHP application * the number of simultaneous connections, but that is hardly ever the case, since Apache will be reusing the same high memory processes for every jpg and css file that it does for all of the php requests and 2-3 simultaneous users can make 20-30 concurrent requests. You better make sure that your maxclients is set to your physical memory divided by your php app's memory use. In a 1G VPS this might be 1024M/64M = 16. Save some memory for MySQL if it is on the same server and you probably shouldn't have MaxClients over 10. Now all of the css, jpg and png files are waiting in-line for the 500ms php scripts to finish and the site loads slow. Many PHP apps eat up over 128M per process, even though a typical request is smaller, that one crazy request eventually bloats all of the processes and you are swapping. If PHP starts hitting swap, your request times are rising up to 3-5 seconds real quick.
As far as I know, nginx can do anything Apache can do. nginx is generally faster than Apache. Apache can include modules without a recompile, nginx often requires you recompile to add features. nginx can be used as a reverse-proxy, a load balancer, or a thin SSL / SPDY layer, and succeed; Apache isn't as well suited to non-traditional web serving.
Personally, I find nginx's configuration syntax nicer to read and write than Apache's.
LAMP is fine for small experimental websites. Do what you're comfortable with! The scale at which the differences between nginx and Apache actually matters is pretty large.
Anyone trying to argue for nginx on the basis of better feature support (over apache) is blind to the reality of things.
There's a list of all the official Apache modules at https://httpd.apache.org/docs/current/mod/. Also, there are many third party modules.
Apache can serve as a reverse proxy to a web server, or even a fully functional forward proxy for lan users to the internet.
Nginx was never meant to have more features than Apache, it's intended to be lightweight and fast.
If you can imagine it, Apache is likely to have a module for it. With nginx, not so much.