phpinterpreterfastcgimod-php

mod_php vs cgi vs fast-cgi


I have been trying to understand the exact meaning/purpose of loading php as an apache module vs the rest.

When php is installed as an apache module, what exactly happens? For example, does reading the php-ini file happen every time the php request comes or when the php module is loaded alone?


Solution

  • php.ini is read when the PHP module is loaded in both mod_php, FastCGI and FPM. In regular CGI mode, the config file have to be read at runtime because there's no preforked processes of any kind.

    I think the only real advantage of running PHP as a module inside the web server is that the configuration might be easier. You get a lot better performance when you run it in FastCGI or FPM mode and can use a threaded or evented (instead of forked) Apache, or when you can throw out Apache altogether.