6月 122014
 

Most administrators know that PHP, the widely used scripting language, can be embedded in HTML and works with all major web servers. What’s less widely known, however is that you can run PHP in different ways on your server. The most common option is the mod_php module that’s runs by default in the Apache HTTP Server. If your primarily goal is performance, however, you should consider other options. PHP-FPM (FastCGI Process Manager) and PHP FastCGI each have pros and cons, but either can speed up the performance of your PHP.

mod_php

Let’s start by looking at running Apache with mod_php. This package is present in just about every Linux distribution’s repository, so installing it is easy, and so is configuring and managing the software. In fact, its ease of use may be the main reason to deploy mod_php.

With mod_php the PHP interpreter is “embedded” inside the Apache process; Apache doesn’t call any external PHP process, which means that Apache and PHP can communicate better. However, every single Apache child must load mod_php, which results in a bigger process than necessary being used for serving static resources such as image files, CSS, and JavaScript.

Another problem with this method is that it works only on Apache. This is not always an issue, as Apache is the most complete web server you can find, but websites that run on small virtual private servers (VPS), or big sites that have to serve million of pages a day, might want a different web server that can scale up or down better than Apache, and would therefore need a different way to run PHP too.

Pros:

  • Easy to install and update.
  • Easy to configure with Apache.

Cons:

  • Works only with Apache.
  • Forces every Apache child to use more memory.
  • Needs a restart of Apache to read an updated php.ini file.

Continue reading »

6月 122014
 

我在网上查fastcgi与php-fpm的关系,查了快一周了,基本看了个遍,真是众说纷纭,没一个权威性的定义。

网上有的说,fastcgi是一个协议,php-fpm实现了这个协议; 有的说,php-fpm是fastcgi进程的管理器,用来管理fastcgi进程的; 有的说,php-fpm是php内核的一个补丁; 有的说,修改了php.ini配置文件后,没办法平滑重启,所以就诞生了php-fpm; 还有的说PHP-CGI是PHP自带的FastCGI管理器,那这样的话干吗又弄个php-fpm出来,我就更晕了;

发个贴,想听听大家的理解,网上的我都已经看了个遍,因为我查了一周了,哈哈,所以想听听原创的理解。
======
刚开始对这个问题我也挺纠结的,看了《HTTP权威指南》后,感觉清晰了不少。

首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的, Continue reading »