Skip to content

Instantly share code, notes, and snippets.

@ahmedofali
Last active July 21, 2017 19:00
Show Gist options
  • Save ahmedofali/6a0bbf564eaef924fa68a1e73973932d to your computer and use it in GitHub Desktop.
Save ahmedofali/6a0bbf564eaef924fa68a1e73973932d to your computer and use it in GitHub Desktop.
php specific Important Modules and Jargon Should be know

PHP life Cycle

This is Explanation for the varoius questions about php.

What is php-mod?

mod_php means PHP, as an Apache module. Basically, when loading mod_php as an Apache module, it allows Apache to interpret PHP files (those are interpreted by mod_php).

There are (at least) two ways of running PHP, when working with Apache :

Using CGI : a PHP process is launched by Apache, and it is that PHP process that interprets PHP code -- not Apache itself. Using PHP as an Apache module (called mod_php) : the PHP interpreter is then kind of "embedded" inside the Apache process : there is no external PHP process -- which means that Apache and PHP can communicate better.

using CGI or mod_php is up to you : it's only a matter of configuration of your webserver.

To know which way is currently used on your server, you can check the output of phpinfo() : there should be something indicating whether PHP is running via mod_php (or mod_php5), or via CGI, Using " Server API ".

You might also want to take a look at the php_sapi_name() function : it returns the type of interface between web server and PHP.

If you check in your Apache's configuration files, when using mod_php, there should be a LoadModule line looking like this :

LoadModule php5_module modules/libphp5.so (The file name, on the right, can be different -- on Windows, for example, it should be a .dll) [ Edited From Stack Overflow Question https://stackoverflow.com/questions/2712825/what-is-mod-php ]

What is cgi?

A PHP process is launched by Apache, and it is that PHP process that interprets PHP code -- not Apache itself.

Interface Which tells webserver => how to pass data ( input => Request Information ) throw envirnment variables to => Programming Language And then Recieve Response ( Output ) and return it to webserver to send it to the client.

It's Old but some developers still use it, the others use mod_php as an apache module that interprets php code because it's bundled within apache so it's fast rather than calling cgi that starts new php process start the request - response process.

What is FCGI?

A faster, more recent and probably more secure(?) alternative to CGI is FCGI and there is a PHP-FCGI module available which is the way to go if you insist on the CGI way but not the PHP-FPM option.

What is PHP-FPM?

FPM is a process manager to manage the FastCGI SAPI (Server API) in PHP. Basically, it replaces the need for something like SpawnFCGI. It spawns the FastCGI children adaptively (meaning launching more if the current load requires it).

Otherwise, there's not much operating difference between it and FastCGI (The request pipeline from start of request to end is the same). It's just there to make implementing it easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment