Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

PHP Handler Engines Explained

Thursday, December 21st, 2017 by Servage

phpAlmost all PHP developers must have heard of either mod_php, PHP-FPM or FastCGI before. However, you might not be aware of what they actually are and do behind the scenes of a web server or how they are different from each other. These handlers are a base requirement for the PHP language to run on web servers so it’s good to know how they operate.

PHP Handlers Explained Briefly

Regardless of what PHP handler a web server uses, the process of executing PHP code is mostly the same. A web server receives a request to serve a PHP page. It then sends the request to a PHP handler which processes the request, and finally the web server returns the result.

mod_php

mod_php is a common way to execute PHP code on a server. In this scenario, PHP is executed by an Apache module called mod_php. The PHP interpreter lies inside an Apache process and there is no separate process for PHP. This allows for a fast communication between Apache and PHP and is one of the reasons why mod_php generally performs very well even on large websites with lots of PHP code. However, mod_php tends to require more memory than other PHP handlers. One of the reasons for this is that the PHP interpreter is loaded even if no PHP code is executed.

FastCGI

FastCGI is an improved version of an older handler called CGI. Unlike mod_php, FastCGI processes PHP code in a separate process. This means a new process has to be created when PHP code is executed, which makes it perform worse than mod_php. However, it regains some performance by not loading the PHP interpreter when processing static content. It is also considered more secure since PHP code is not executed inside the web server process. In general, FastCGI is only recommended for small PHP websites, but since both FastCGI and CGI has been around for a long time, it can commonly be seen on servers.

PHP-FPM

PHP-FPM (PHP FastCGI Process Manager) is an improved version of FastCGI. The most notable improvements are related to performance for a PHP website of any type and size. PHP-FPM also comes with some useful security features to help isolate PHP code from other processes and users on a server.

Conclusion

In conclusion, there are a few PHP handlers to choose from. Some of them are older and some newer, some faster and some more secure than others. PHP-FPM is a relatively new and modern handler while mod_php is the good old way to execute PHP when using Apache. If you’re not using Apache, PHP-FPM and Nginx is a common combination for new websites and servers.

PHP Handler Engines Explained, 4.7 out of 5 based on 3 ratings
Categories: Tips & Tricks

Keywords:

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.