我正在使用这个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实现不再可用了.
原文链接:https://www.f2er.com/nginx/435047.html我的答案刚刚被投票(在线上一段时间后),我明白为什么,所以这里列出了为什么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
andSTDERR
.- 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