The Difference Between PHP as Apache Module and CGI Binary?

Let’s suppose PHP is a computer program that, when text is sent, translates the whole thing into a matrix and returns it as output. There are two different ways that we can run this program:

  • We can integrate it into a larger program in order to make the original one a module of that larger program.
  • We can make it a standalone system which we can call whenever we need to convert text to uppercase.

If we want to use the capabilities of PHP as mentioned above, we can run it in two ways. Let us talk in full detail about the two.

As an Apache Module

Other programs may be incorporated as part of Apache. So when it’s merged with PHP, what PHP can do is built into Apache. PHP is therefore regarded as an Apache module.

As a CGI

If we install a standalone version of PHP on the web server, Apache will not know how to execute PHP code. What it does know is how to call another computer program and then get the output.


Apache: It can modify certain PHP sessions found in the .htaccess file because PHP is not separate from Apache. In a shared hosting environment, this means that you can override some php.ini master settings.

CGI: Apache can not alter the configuration of PHP since it is not part of Apache. If you don’t install suPHP, each user can not override the settings.

Please visit also:  How to optimize Apache Server for Better Performance


Apache: This is faster since PHP is ready to run.

CGI: The PHP program has to be read from memory, parsed and then compiled each time a request is made, making this option slower.


Apache: Being a part of Apache, PHP is launched one-time and runs continuously, so you can’t run it as any other user except for nobody. With user nobody, you have to loosen permissions so it can write to your files.

CGI: With suPHP, PHP is run as the actual userID. Since PHP runs this way, you don’t have to loosen permissions for it to write to your files. And since it runs as you, it won’t be able to access other files of other accounts on a shared server, thus reducing security risks.

Add a Comment

Your email address will not be published. Required fields are marked *


My name is Nohman Habib and I am a web developer with over 10 years of experience, programming in Joomla, Wordpress, WHMCS, vTiger and Hybrid Apps. My plan to start is to share my experience and expertise with others. Here my basic area of focus is to post tutorials primarily on Joomla development, HTML5, CSS3 and PHP.

Nohman Habib


Request a Quote

PHP Code Snippets Powered By :