nginx - 使用 Nginx Web 服务器的 FastCgi 与 PHP-FPM

标签 nginx memcached fastcgi php xcache

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

本教程使用 ISPConfig 3,并且可以选择是使用 FastCgi 还是 PHP-FPM。

我想知道两者哪个更好。就性能和速度而言,两者中哪一个与 nginx 内联使用最好?

顺便说一句,我还在我的服务器上启用了 memcached 和 xcache。

最佳答案

PHP-FPM 比 PHP 的旧 FastCGI 处理要好得多。从 PHP 5.3.3 开始,PHP-FPM 已成为核心,旧的 FastCGI 实现不再可用。

我的答案只是被否决了(在上线相当长一段时间之后),我明白为什么,所以这里列出了为什么 PHP-FPM 实际上比旧的 FastCGI 实现更好。

首先,PHP 社区中的 FastCGI 实现很糟糕这一点早已众所周知。可以在 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 - fastcgi_finish_request() - Slowlog with backtrace

关于nginx - 使用 Nginx Web 服务器的 FastCgi 与 PHP-FPM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17141596/

相关文章:

ssl - NGINX:两个不同的 websocket 连接的不同日志

php - Nginx + PHP、Node.js 和 jQuery 设置

python - pip 安装 python3-memcached 失败

ruby - 通过 Apache mod_fcgid 服务的 Redmine 2.4.2 返回错误 500

php - 使用docker-compose在Docker中运行laravel/lumen

apache - 如何配置HTTPS Nginx + Pagespeed + Varnish + Apache?

php - 基于高流量百分比的集合选择?

caching - memcached 与基于数据库的键值表?

c++ - 从哪里开始使用 FastCGI 和 C++

ubuntu - ubuntu 上 Fastcgi 的问题