APC (PHP Cache) Uptime 0 minutes, not caching

Jussi asked:

My goal is to implement APC for opcode cache for a drupal 6 production site.
I have so far tested APC with several php files with and without including other php files with include_once.

Also tried to tweak the apc.ini values for shm_size, apc.include_once_override and apc.stat.
Restarted apache every time.

Resulting in apc.php not showing any changes in any values. (except of course the changed apc.ini values are shown as they should)

Every time i refresh the apc.php test page, the start time resets as the current time showing uptime 0 minutes.

apc.php -testpage shows:

General Cache InformationAPC Version    3.1.9
PHP Version 5.2.10
APC Host    xxxx.xx.xx
Server Software Apache/2.2.3 (CentOS)
Shared Memory   1 Segment(s) with 128.0 MBytes
(mmap memory, pthread mutex Locks locking)
Start Time  2011/07/26 11:53:56
Uptime  0 minutes
File Upload Support 1

Cached Files    0 ( 0.0 Bytes)
Hits    1
Misses  1
Request Rate (hits, misses) 2.00 cache requests/second
Hit Rate    1.00 cache requests/second
Miss Rate   1.00 cache requests/second
Insert Rate 0.00 cache requests/second
Cache full count    0

Cached Variables    0 ( 0.0 Bytes)
Hits    0
Misses  0
Request Rate (hits, misses) 0.00 cache requests/second
Hit Rate    0.00 cache requests/second
Miss Rate   0.00 cache requests/second
Insert Rate 0.00 cache requests/second
Cache full count    0

apc.cache_by_default    1
apc.canonicalize    1
apc.coredump_unmap  0
apc.enable_cli  0
apc.enabled 1
apc.file_md5    0
apc.file_update_protection  2
apc.gc_ttl  3600
apc.include_once_override   0
apc.lazy_classes    0
apc.lazy_functions  0
apc.max_file_size   16
apc.mmap_file_mask  /tmp/apcphp5.095eRm
apc.num_files_hint  1024
apc.report_autofilter   0
apc.rfc1867 0
apc.rfc1867_freq    0
apc.rfc1867_name    APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_
apc.rfc1867_ttl 3600
apc.serializer  default
apc.shm_segments    1
apc.shm_size    128M
apc.slam_defense    0
apc.stat    0
apc.stat_ctime  0
apc.ttl 7200
apc.use_request_time    1
apc.user_entries_hint   4096
apc.user_ttl    7200
apc.write_lock  1

Host Status Diagrams:
 Free: 128.0 MBytes (100.0%)     Hits: 1 (50.0%)
 Used: 20.3 KBytes (0.0%)    Misses: 1 (50.0%)

Detailed Memory Usage and Fragmentation:
Fragmentation: 0%

phpinfo shows:

Server API  CGI/FastCGI

Version     3.1.9
APC Debugging   Enabled
MMAP Support    Enabled
MMAP File Mask  /tmp/apcphp5.JkKDk7
Locking type    pthread mutex Locks
Serialization Support   php
Revision    $Revision: 308812 $
Build Date  Jul 21 2011 14:31:12

I followed these steps to find if suexec settings would prevent caching:

[root@host /]# ps -ef|grep lsphp
root     20402 17833  0 11:21 pts/0    00:00:00 grep lsphp

[root@host /]# ps -waux
root     17833  0.0  0.1   5004  1484 pts/0    S    10:39   0:00 bash

..indicates that there is no lsphp running on the host

also I read the following article and comments, concluding that in my case the problem is not the suexec as the user apache is the httpd process owner

also suexec command is not recognized when logged and launced as root @ host

also i’m almost confident that there is no cPanel running on the host to check if a setting there would reset the running cache process at some interval

This leaves me with few clues where to head next.
I tried to set (with chown and chgrp) apache as the owner of the apc.php file and some test php files resulting in 500 server error.

Is there a way to check if the file permissions prevent the apc stay running?
I’m tremendously grateful for any suggestions or help.

My answer:

Your configuration shows that apc.max_file_size is set to 16 bytes. So no file larger than 16 bytes (and ALL of them are!) will be cached. I would reset this to the default of 1M.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.