Apache Nginx Thailand Guide
Contents
What is Web Server
A web server is software that receives HTTP requests from browsers and sends back responses — HTML files, CSS, JS, images, or PHP/Python output. It acts as the intermediary between the browser and the application.
What is Apache
Apache HTTP Server is the oldest and once most popular web server, launched in 1995. Open source and free, using process-based architecture (Pre-fork MPM) creating separate processes or threads per connection. Easy per-directory configuration via .htaccess.
What is Nginx
Nginx (pronounced Engine-X) launched in 2004 to solve the C10K Problem (10,000 simultaneous connections). Uses event-driven architecture without blocking — ideal for high traffic. Faster than Apache for static files and popular as a reverse proxy.
Overview
Apache Pre-fork creates new processes per connection — more memory usage but better process isolation. Nginx uses a single event loop handling many concurrent connections without blocking — less memory, handling far more simultaneous connections.
Performance: Apache vs Nginx
For static files, Nginx is 2-5× faster than Apache. For PHP (dynamic content), the difference shrinks because PHP execution is the main bottleneck, not the web server. Nginx uses less memory — better for low-RAM VPS. Apache is more flexible for per-directory configuration.
Static vs Dynamic Content
For static files (HTML, CSS, JS, images): Nginx clearly wins. For dynamic content (PHP, Python): configuration matters more. Apache uses mod_php running PHP in its own process. Nginx requires separate PHP-FPM (FastCGI), which is actually faster than mod_php.
Configuration
Apache .htaccess enables per-directory configuration without server restart — ideal for shared hosting where each user needs separate config. Nginx lacks .htaccess; configuration is in server.conf requiring a reload. Less flexible for shared hosting but faster.
Use Case Apache Nginx
Apache is ideal for shared hosting, sites needing .htaccess, and legacy apps configured for Apache. Nginx suits high-traffic sites, static file serving, reverse proxying Node.js/Python apps, low-RAM VPS, and modern WordPress.
Choosing: LiteSpeed
LiteSpeed Web Server is a commercial web server compatible with Apache configuration but much faster. OpenLiteSpeed is the free open-source version. The LiteSpeed Cache plugin for WordPress makes it the fastest web server option for WordPress.