How to choosing PHP module for Apache



Since I use my old 2 years hosting server. It's time to upgrade to new server with high performance to support more customers. So I have to research about installation and tuning DirectAdmin. One factor that is very important is Apache. There are many differ performance between system with tuning and without.

Factors that we have to think about choosing PHP module for Apache are performance and security. Some modules come with great performance but trade off with security while some modules are opposite.

While googling, I found some interesting data Benchmark Comparison on Serving Simple PHP: LiteSpeed vs Apache vs Nginx so I choose only mod_php, mod_fastcgi, mod_fcgid and suPHP to compare and analysis in this article.

The difference between each Apache PHP modules are

  • mod_php is module that run with single user. It is the fastest module as you can see above benchmark. But it is less security because its method that use single user to run all php script.
  • suPHP is module that run with each user. suPHP will create each processes to handle each users. So if some users has been hacked. It will not affect to the others users. But this method is come with less then 50 times performance compare to mod_php
  • mod_fastcgi and mod_fcgid are the same as suPHP except it will reserve memory and process for each users. So it will more faster than suPHP but require much more resources than suPHP
  • mod_fastcgi and mod_fcgid concept are the same but difference in term of implement as you can see performance that nearly the same.

So what should we choose?

Use mod_php if

  • You have only one website on the server or you are the only one that take care this server
  • Heavy load website and want performance

Use suPHP if

  • You have server that is hosting provider or having many website access to the same server.
  • Small load on each website and you have small resource of your server

Use mod_fastcgi or mod_fcgid if

  • You have server that is hosting provider or having many website access to the same server.
  • Heavy load website and you have the great server

If you have any others ideas, please tell me what you think.