As a developer you might not care too much about which PHP handler is running your application within the server. However you still have multiple options to choose from, depending on what the site you are running requires. Here are some different ways you can run PHP.
Running PHP using Apache Only
Alongside with its high operating speed mod_PHP requires less CPU power and memory usage. You will also have access to an Apache server which comes along as a default. If have resource or memory limitations, and you don’t need much security, mod_PHP could be the solution you are looking for. CGI has the capacity to see the PHP as another user. Its speed is slower than that of the mod_PHP, due to the fact that it needs more CPU time to resolve file permission issues.
SuPHP is able to run PHP scripts as another user. It does however require more memory usage and CPU power. This solution is best utilised for servers that are running multiple websites. Because PHP scripts can be run as different users, it can better your security. As any data that might be at risk can be isolated to the website only, shielding your server in the process.
Running PHP using Apache and Nginx
FastCGI can offer your some of the same benefits that suPHP has as well. Usage of Opcache is allowed, therefore resulting in high performance speeds. The only downfall is its big consumption of memory. PHP-FPM has the ability to save any type of queries, when work is stopped, without the risk of losing them when it is launched again. It can offer a dynamic number of processes, taking in account the size of the load. But PHP-FPM comes with a cost in memory usage and CPU power, as it needs a lot of it. Best utilised when using VPS or dedicated servers, but keep in mind that with shared hosting you will lose your quota fast.
HHVM comes with JIT compilation, enabling it to act as Java, offering high performance speed and additional tools. Bear in mind that HHVM is a relatively new technology and as such it does not come with the best support for its features and tools. Having experience with rolling your own servers is something you should have if you are to use HHVM for PHP. Although its speed is ideal for big amounts of traffic, many hosting providers have very little experience working with HHVM.
There is more than one way you can run your PHP. Finding the best solution is a decision best made by understanding the requirements and nature of your website. If you have any other questions or you seek more information please feel free to contact our team at www.bytehouse.co.uk/contact.