Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose we have a typical LAMP setup. When a person requests a web page coded in php, what happens at the Apache level? Does Apache create a new php instance to create and return that web page? Or is there a continuous php instance running at all times?

Basically, here is how I think it works:

  • Person visits

  • Apache receives the request, spins up an instance of php to create the page

  • Page is created, sent back to the requesting browser

  • PHP instance is closed

Thus, only one php instance deals with page requests...Is my thinking correct on this?

share|improve this question
Depends. mpm-prefork uses "workers" that execute the PHP and pass the result back, while mpm-worker uses Apache's internal workers and mod_php to execute. – Nathan C Oct 1 '13 at 14:18
up vote 2 down vote accepted

It depends on how you are utilizing PHP. If you're not utilizing CGI/FastCGI (which would make your statement correct) then PHP is actually run in a module (see /etc/httpd/conf.d/php.conf, or httpd.conf for the include php module). Which means that when Apache has a kid, each process already has a binary of PHP. So, Apache runs the interpreter against a set of hooks and the page is rendered.

CGI is the method which is executed as a single process.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.