Apache

Apache HTTP Server has been the default web server for PHP development for most of the language’s history. The Zend Framework Book assumes Apache throughout, and a dedicated chapter covers virtual host configuration for local development. If you are running a PHP application in production or setting up a local environment, understanding Apache’s role in the request pipeline matters.

Apache and PHP

Apache serves PHP through handler modules. In the past, mod_php was the standard approach, embedding the PHP interpreter directly into each Apache worker process. This was simple to configure but meant every Apache process carried the memory overhead of the PHP runtime, even when serving static assets like images, CSS, and JavaScript files.

The modern approach uses PHP-FPM (FastCGI Process Manager) with Apache’s mod_proxy_fcgi or mod_fcgid. PHP-FPM runs as a separate process pool, and Apache forwards PHP requests to it over FastCGI. This separation lets Apache handle static files efficiently while PHP processes are managed independently with their own pool sizing, timeouts, and resource limits.

Both approaches work. For local development, mod_php is often the path of least resistance. For production, PHP-FPM gives you more control and better resource utilisation. The Local Development Environments for Legacy PHP guide covers setting up both options.

Virtual Hosts

Virtual hosts allow a single Apache installation to serve multiple sites, each with its own domain name, document root, and configuration. In PHP development, this means you can run myproject.local and another-project.local on the same machine, each pointing to a different project directory.

The Creating a Local Domain Using Apache Virtual Hosts chapter walks through the setup process for Zend Framework projects specifically. The core configuration involves a <VirtualHost> block that maps a ServerName to a DocumentRoot, paired with a hosts file entry that resolves the domain to 127.0.0.1.

Name-based virtual hosting is what most PHP developers use locally. Port-based and IP-based virtual hosting exist but are rarely needed for development work. The glossary entry for Virtual Host covers the concept in brief.

mod_rewrite and .htaccess

Zend Framework applications, like most modern PHP frameworks, route all requests through a single front controller file (typically index.php). Apache’s mod_rewrite module makes this possible by rewriting incoming URLs so that requests for /blog/view/42 are internally redirected to index.php, where the framework’s router takes over.

The standard .htaccess configuration for a ZF1 application looks roughly like this: enable the rewrite engine, set a base path, and create a rule that sends everything except existing files and directories to index.php. This pattern has survived unchanged into modern frameworks. Laravel, Symfony, and Laminas all use essentially the same approach.

Understanding mod_rewrite is worth the investment. The rules can be cryptic, especially when regular expressions are involved, but the basic front controller rewrite pattern is something you will configure once and rarely touch again. Problems arise when mod_rewrite is not enabled, when AllowOverride is set too restrictively for .htaccess files to take effect, or when multiple rewrite rules conflict.

The Architecture chapter explains how the front controller receives these rewritten requests and dispatches them through the routing and controller layers.

Apache vs Nginx

Nginx has become the dominant alternative to Apache for PHP hosting. It handles static files and concurrent connections differently, using an event-driven architecture rather than Apache’s process-per-connection model. For high-traffic sites, Nginx with PHP-FPM is a common production stack.

That said, Apache is far from obsolete. It has mature support for .htaccess per-directory configuration, a wide range of modules, and deep integration with hosting control panels. Many shared hosting environments still run Apache exclusively. If your application was built with .htaccess rewrite rules and per-directory configuration, moving to Nginx means translating those rules into Nginx’s configuration syntax, which is a different format entirely.

For the purposes of the book content, Apache is assumed. But the PHP application logic, the front controller pattern, the routing, and the entire MVC layer are web server agnostic. The same Zend Framework application can run behind Apache, Nginx, or any server that can forward PHP requests to the interpreter.

Glossary Terms

  • Virtual Host - Apache configuration for serving multiple domains
  • Front Controller - the single entry point pattern that relies on URL rewriting
  • Request Lifecycle - the full journey of an HTTP request through server and application

See PHP for language-level context, Performance for optimisation strategies, and Zend Framework for the framework that the book’s Apache configuration supports.