How to make APC (PHP Cache) work?

一世执手 提交于 2019-11-30 02:06:24

APC can be used in two ways:

  1. As an opcode cache. You have support enabled so this is working; and
  2. As a general cache. You have to explicitly use the API for this.

(1) is the main benefit. It reduces time for script execution by storing the opcode results of "compiling" scripts.

As for it working, from the installation instructions:

Note: On Windows, APC needs a temp path to exist, and be writable by the web server. It checks TMP, TEMP, USERPROFILE environment variables in that order and finally tries the WINDOWS directory if none of those are set.

So you shouldn't need it (or see any activity) on CentOS.

That being said, require/include are better than require_once/include_once/autoload but it should only matter if you are doing that with hundreds of files.

Is your site basically one PHP file that then includes or requires other files? That may register as just a single file. Also, as far as I know, conditional include/require logic may not cache as expected though that may just be hearsay!

Did you check thr log files? take a look at /var/log/apache2/error.log or however its named under your distribution.

Also, try to make 2-3 php files, point thebrowser at them, and then check how many php files are cached by the APC cache..

Not sure about APC, but i'd recommend Eaccelerator (http://eaccelerator.net/). I've tested it some time ago and really made a difference.

Benjamin Cremer

APC actually doesnt share cache between proceses. Try to configure your PHP-Process to fork Childs and let the Master PHP-Process stay running.

See: How to share APC cache between several PHP processes when running under FastCGI?

In the APC 3.1.5dev branch, a new option was introduced allowing you to disable the opcode cache. It appears to be turned off by default.

Try adding this to your APC config file:

apc.enable_opcode_cache=1

http://www.litespeedtech.com/support/forum/showthread.php?t=3761

"APC does not work well with PHP suEXEC as each PHP process will use its own cache memory, not shared.

You should try eAccelerator + /dev/shm if you need to use PHP suEXEC."

well got same problem, it seems PHP suEXEC + APC is problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!