加入收藏 | 设为首页 | 会员中心 | 我要投稿 大庆站长网 (https://www.0459zz.com/)- 科技、智能边缘云、事件网格、云计算、站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

FastCgi和PHP-FPM使用Nginx Web服务器

发布时间:2020-11-14 18:35:28 所属栏目:Nginx 来源:互联网
导读:我正在使用这个tutorial在我的新的Web服务器上安装nginx,php和mysql.本教程正在使用ISPConfig 3,并且有一个选项是使用FastCgi还是PHP-FPM.我想知道哪个是更好的两个.在性能和速度方面,哪两个最适合与nginx一起使用?BTW,我也在我的服务器上启用了memcached和x

我正在使用这个tutorial在我的新的Web服务器上安装nginx,php和mysql.

本教程正在使用ISPConfig 3,并且有一个选项是使用FastCgi还是PHP-FPM.

我想知道哪个是更好的两个.在性能和速度方面,哪两个最适合与nginx一起使用?

BTW,我也在我的服务器上启用了memcached和xcache.

最佳答案 PHP-FPM比旧的FastCGI处理PHP好多了.从PHP 5.3.3 PHP-FPM是核心的,旧的FastCGI实现不再可用了.

我的答案刚刚被投票(在线上一段时间后),我明白为什么,所以这里列出了为什么PHP-FPM实际上比旧的FastCGI实现更好.

首先,众所周知,FastCGI实现在PHP社区中是不好的.一个可以在https://wiki.php.net/ideas/fastcgiwork找到的文件的页面,它说:

php-cgi is not useful in production environment without additional “crutches” (e.g. spawn-fcgi from lighttpd distribution or php-fpm patch). This project assumes integration of such “crutches” and extending php-cgi to support for different protocols.

  • daemonization (detach,pid file creation,setup environment variables,setuid/setgid/chroot)
  • graceful restart
  • separate and improve transport layer to allow support for different protocols
  • support for SCGI protocol
  • support for subset of HTTP protocol

这是PHP-FPM从http://php-fpm.org/about/开始做得更好的事情的列表:

  • PHP daemonization: pid file,log file,setsid(),setuid(),setgid(),chroot()
  • Process Management. Ability to “gracefully” stop and start PHP workers without losing any queries. This allows gradually updating the configuration and binary without losing any queries.
  • Restricting IP addresses from which requests can come from.
  • Dynamic number of processes,depending on the load (adaptive process spawning).
  • Starting the workers with different uid/gid/chroot/environment and different php.ini options (no need for safe mode).
  • Logging STDOUT and STDERR.
  • Ability to emergency restart all the processes in the event of an accidental destruction of the shared memory opcode cache,if using an accelerator.
  • Forcing the completion of process if set_time_limit() fails.

Additional features:
– Error header
– Accelerated upload support
– 07002
– Slowlog with backtrace

(编辑:大庆站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读