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

前端之家收集整理的这篇文章主要介绍了FastCgi和PHP-FPM使用Nginx Web服务器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在使用这个tutorial在我的新的Web服务器上安装Nginx,PHPMysqL.

本教程正在使用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

原文链接:https://www.f2er.com/nginx/435047.html

猜你在找的Nginx相关文章