arrow_back
Back

PHP web servers: Apache, Nginx, PHP-FPM, and IIS

Andrew Dorokhov Andrew Dorokhov schedule 2 min read
menu_book Table of Contents

PHP can work either as a CLI scrip or a as module for a web server.

There are several web server options available for using PHP.

  • Apache HTTP Server: Apache is one of the most widely used web servers and supports PHP through the use of the mod_php module.
  • Nginx: Nginx is a high-performance web server known for its scalability and efficient handling of concurrent connections. It can be used with PHP via FastCGI or PHP-FPM (FastCGI Process Manager).
  • IIS: IIS is the web server provided by Microsoft for Windows-based servers. It can run PHP applications using the PHP module or PHP-FPM.
  • Lighttpd: Lighttpd is a lightweight web server designed for speed and efficiency. It can be used with PHP through FastCGI.

Apache vs Nginx in practice

Further reading: open_in_new Apache vs Nginx: a practical view .

Summary: Nginx handles thousands of concurrent connections easily, stays lightweight, and excels at serving static files.

Apache

  • Flexibility — dynamically loadable modules (many language interpreters).
  • MPM modules for multiprocessing:
    • mpm_prefork
    • mpm_worker
    • mpm_event

Nginx

  • Handles on the order of 10,000 concurrent connections.
  • Lightweight and very strong for static content.
  • Designed to hand off dynamic requests to other software (PHP-FPM, uWSGI, etc.).

Administrators often pick Nginx for efficient resource use and responsiveness under load, and because it works well as both a web server and a reverse proxy.

To run PHP behind Nginx, use one of: HTTP, FastCGI, SCGI, uWSGI, or memcache.

Further reading: open_in_new Nginx, PHP-FPM — what is it?

code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Composer: PHP dependency management and autoloading

arrow_forward