L.A.M.P. is a known acronym that describes a server with GNU/Linux as the operating system, some version of Apache for serving web files, MySQL as the database and PHP for the preferred scripting language.
Since performance has entered a privileged place due to overall increased complexity of internet sites, a new acronym has surfaced in recent years: L.E.M.P.
The main difference is basically using Nginx (try to pronounce LNMP three times fast) instead of Apache for the webserver. Keep on reading to know if this could be of use to you.
The Russian Webserver
Less known than Apache, with a less fancy site and out of nowhere, this tiny piece of software took the Internet by storm.
Apache has been the king of the world when it comes to sheer number of installations. It grew to a point where it blew the competition out of the water. The problem was that with its approach to modules and multi-process, it chews memory like there is no tomorrow.
Since version two, there are official variants that use different methods of multi-process. Threads for instance are nicer on memory usage but more taxing on CPU and due to the way they work, modules needed to be thread-safe, shortening the list of compatible ones.
Nginx slowly but surely appeared into view, and to make a long story short: Today when we talk about performance, we usually mention Nginx. And even there are some configurations where we still have Apache but behind Nginx, since it’s also a proxy server and load balancer.
Two of the major reasons: less memory footprint and capable of handling a lot more of simultaneous connections. It has its downsides, like having to write redirect rules inside the configuration files (no Apache like htaccess for you) and since it has no modules support, you usually need to reconfigure and recompile if you need to add more functionality. Not a major inconvenience but Apache is great for adding new functionality in real-time (or disabling it if you don’t need it).
This scenario lead to a fierce competion and Apache just announced that the upcoming 2.4 version is going to focus in performance, and they mention Nginx as the main reference. In the end, it doesn’t matter which one has the most performance because we all win.
Let’s get to the details
Well, since we don’t have dynamic loaded modules in Nginx, we also don’t have mod_php (of course), so we have to relay on the standalone version of PHP and communicate through CGI, which is a standard way of connecting web servers with applications that usually spit back dynamically generated HTML.
In this case, we loaded Nginx and used PHP-FPM (website here), which the site describes perfectly: “PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.”. Worth mentioning as well is that we used GNU/Linux Debian 18.104.22.168 64 Bit as the operating system and added alternate caching for PHP called APC.
MySQL is installed as usual, ready to be used.
We also added a test site that you can use to check that everything is working and as a starting point as well. To test the new server, put the following line in your hosts file:
And then just point your browser at http://samplesite.com
The test site is located under /www/samplesite.com and the configuration file in /etc/nginx/sites-available/samplesite.com, ready to be modified at your discretion.
While Nginx is geared towards great performance, it’s not a magical solution. This image is setup with default and basic parameters, so you will have to adapt the configuration file according to the capabilities of your virtual machine. Just in case, the default configuration works nicely with even the most basic City Cloud profile (“small”).
In a future article, we’ll tell you how you can tweak Nginx and PHP parameters to squeeze as much juice as you can out of your server.
Nonetheless, you have this image already available in the App Center. You can go there and start using it right now, with a few clicks.