Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running PHP 5.3.4, Apache 2.0.63 and APC 3.1.7 on my VPS with CentOS 5.

When I open up apc.php and go the the system cache entries tab, it is telling me that the only file in the cache is apc.php. I have accessed multiple other files in the same directory and still it seems like they aren't getting cached.

I have played with apc_store and apc_fetch. I can store and fetch variables from the same request but not across multiple requests.

I have searched all over the web and turned up nothing that helped me out. I thought I had figured it out once when someone claimed that a but in APC 3.1.6 was causing the issue. I downloaded 3.1.7 and built it from improvement. I still had the same issue. I have restarted the httpd service multiple times with no success.

Any suggestions what to try and what might be wrong?

share|improve this question
up vote 1 down vote accepted

Are you using mod_fcgid? If so, don't. mod_fcgid doesn't support PHP's child-spawning capability, so it will spawn a new PHP if there are multiple requests, and each PHP spawned by mod_fcgid will have its own opcode cache (along with a bunch of useless children if you enabled them in PHP's wrapper script).

If you're using mod_fastcgi, then you'll need to check that mod_fastcgi is only starting one PHP process, and that one PHP process is starting enough children to handle your load. This blog post is a pretty good rundown of the whole thing, though it's specifically for using suexec and getting separate fastcgi processes for each user, you'll need to tweak it to get one fastcgi process for the entire server if that's what you want.

If you're using mod_php5 then it should Just Work, since the APC cache is created by apache.

If you're using CGI without either mod_fastcgi/fcgid, then your PHP executable exits after every single request, taking its opcode cache with it.

share|improve this answer
After checking out apache.conf, I discovered that I am using mod_suphp. Is this the problem? If so, what do I need to do to correct it? – Icode4food Feb 15 '11 at 13:24
mod_suphp executes the CGI binary, which runs one script then dies. I don't think you can easily use any kind of caching with any of the su* extensions, what if user X gets access to user Y's cache? You might be able to get away with using mod_fastcgi with a copy of the php-cgi binary (suid each user) and a separate process pool for every single user that runs scripts, but this will suck RAM like mad if you have more than a couple of users and configuration will be an absolute nightmare. – DerfK Feb 15 '11 at 13:36
If you go with the multiple process pool thing, php-fpm ( ) is designed to make configuring multiple pools and their user/group privileges easy, or at least all in one place. Then you just need to configure apache with FastCGIExternalServer (each user's pool will be a different socket file or port). – DerfK Feb 15 '11 at 13:50
I switched to libphp5 and everything is working fine. Thanks for pointing me in the right direction. – Icode4food Feb 17 '11 at 15:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.