Articles

How ServerPilot Configures Your LAMP/LEMP Stack

ServerPilot configures a LAMP/LEMP stack on your server. LAMP stands for Linux + Apache + MySQL + PHP. As ServerPilot also configures Nginx on your server, this is sometimes called a LEMP stack because Nginx is pronounced "Engine X."

ServerPilot configures Nginx as the public-facing web server because it is much more scalable than Apache. Unlike Apache, Nginx can handle handle tens of thousands of simultaneous client connections. As Nginx waits until it has completely received the request before proxying the request through to Apache, your server is safe from Slowloris attacks. For your SSL-enabled apps, Nginx also provides extremely efficient SSL handling and HTTP/2 support.

The Life of a Request

Static File Requests

Web Browser -> Nginx -> Apache

Every request made by a web browser to your server first goes to Nginx. Nginx proxies the request through to Apache. Apache then processes your application's .htaccess files and rewrite rules. If the request is for a static file, Apache serves the static file. The response goes back through Nginx and then to the browser.

PHP Script Requests

Web Browser -> Nginx -> Apache -> PHP-FPM

When Apache determines that the request is for a PHP script rather than a static file, PHP sends the request to PHP-FPM.

PHP-FPM is the modern PHP FastCGI process manager that is included with PHP. Each of your apps has its own PHP process pool. Each process in the app's process pool runs as the system user your app belongs to (serverpilot by default).

Once PHP finishes processing the request, the response goes back through Apache, then through Nginx, and then to the browser.