Home / Software / PHP module vs PHP CGI binary

PHP module vs PHP CGI binary

PHP logoQuestion: What are the differences between running PHP as an Apache module and running it as a CGI binary on a Linux server?

Answer: One of the biggest differences between a PHP Apache module and a PHP CGI binary is that the Apache module is just that: a module of Apache that is dependent on the web server. They are intrinsically linked. If one goes down, so does the other. A PHP CGI binary is separate program entirely that runs under a different user than the web server. If something goes wrong with PHP, Apache is generally unaffected.

The primary benefit of PHP as a module is speed. When the web server loads, all of the PHP settings and configurations are loaded with it. They stay resident in the memory as long as Apache is resident and running. The drawback is the decreased security of having PHP code run by the Apache user and the fact that any changes to configuration files require an Apache restart. The advantage of PHP as CGI is the stability and security of an independent user running PHP. One of the drawbacks is that it has execute PHP for each instance of a script, which can take a heavier toll on the CPU and create a larger number of processes.

Both methods have benefits and drawbacks, and it is up to the server administrator to decide which is the best for a given situation. Once a policy is set, it is not a good idea to change it, because such a major reconfiguration could adversely affect running scripts and applications. Decide what the best course is for you and stick to it.

Check Also

Uk data center

Professional Data Centres In The UK

A professional data centre is a location in which various pieces of hardware are located …