When PHP is used as a module, it's more-or-less compiled into Apache's code itself. It's loaded for every request which means that it's loaded even for images, scripts, stylesheets and any other files that aren't PHP. It makes serving those pages slower. On the other hand, it makes PHP faster since Apache doesn't have to spawn additional processes.
When PHP is used as a CGI binary, it's more secure but it's slower. Apache can spawn processes under different users which, for example, can increase the security of a shared hosting environment. It also increases stability because the PHP processes are separate from Apache's and in the event of a segfault or other hard crash, PHP processes won't affect Apache. Using PHP as a CGI means that you can't use .htaccess
file configure PHP using php_flag
or php_value
.
The question is, what's more important to you. Speed or security.
If you search for the benefits of using PHP in either CGI or modules on Google, I'm sure you'll find plenty of great articles that may cover things I may have missed.