使用 PHP/Apache 缓存操作码的最简单方法是什么? [英] what is the easiest way for opcode caching with PHP/Apache?
问题描述
我想使用操作码缓存来提高性能
使用 PHP/Apache 缓存操作码的最简单方法是什么?有哪些性能改进?
我已经阅读了有关 xDebug 的文章,但我想知道是否还有更多选择?
我使用 APC 扩展
a> 作为我个人服务器和我们在工作中使用的服务器上的操作码缓存——我几乎从未遇到过任何问题.
安装非常简单:根据您的 Linux 发行版,您可能需要使用类似 :
sudo aptitude install php5-apc
但你不一定有最后一个稳定版本......而且我通常更喜欢使用:
sudo pecl install apc
这将从 PECL 获取最新版本并编译它(注意:您可能需要安装一个名为 php5-dev
的包).
然后你必须配置它;有关您可以配置的指令,请参阅运行时配置.
性能改进可能因您的服务器/应用程序而异,但是,在仅提供 PHP 页面的服务器上(即,如果您的数据库在另一台机器上),您可能会看到 CPU 负载的下降,这是非常重要的(我曾经看到服务器上的 CPU 负载从 80% 上升到 40-50%)
Xdebug 与操作码缓存和性能无关:顾名思义,它对调试很有用.
并且 Xdebug 不应该安装在生产服务器上:当谈到性能时,这可能会很痛苦——我想这是因为它挂钩"到 PHP 中并添加了很多东西,比如记录许多对调试有用的信息;这意味着要做更多的计算——这需要时间和 CPU.
I was thinking to use opcode caching for performance profit
what is the easiest way for opcode caching with PHP/Apache ? and what are the performance improvements ?
I have read about xDebug but I was wondering if there are more options ?
I use the APC extension as an opcode cache on both my personnal server, and on the servers we are using at work -- and I've almost never run into any kind of trouble with it.
Installation is pretty easy : depending on your Linux distribution, you might want to use something like :
sudo aptitude install php5-apc
But you'd not necessarily have the last stable version... And I generally prefer using :
sudo pecl install apc
Which will fetch the last version from PECL and compile it (Note : you'll probably need to installed a package called php5-dev
).
You'll then have to configure it ; see Runtime Configuration for the directives you can configure.
The performance improvements can vary depending on your server/application, but, on a server that only serves PHP pages (i.e. if your DB is on another machine) you might see a drop in CPU load that's quite important (I've seen CPU load go from 80% to 40-50% on a server, once)
Xdebug is not related to opcode caching nor performance : as its name indicates, it's useful for debugging.
And Xdebug should not be installed on a production server : it can be a pain, when it comes to performances -- I suppose it's because it "hooks" into PHP and add lots of stuff, like logging many informations useful for debugging ; which means more calculations to do -- which takes time and CPU.
这篇关于使用 PHP/Apache 缓存操作码的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!