Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.filters 
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.preload_path    
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

APC:
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: http://www.litespeedtech.com/support/forum/showthread.php?t=4189

[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 http://www.brandonturner.net/blog/2009/07/fastcgi_with_php_opcode_cache/

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.

share|improve this question

4 Answers 4

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.

share|improve this answer

Do you have SELinux enabled on that host? Check that with getenforce. If it returns Enforcing, it is enabled.

In case it is enabled and you don't need it, try to temporarily (up to until next reboot, that is) disable it with setenforce 0. Should this resolve your issue and you need to permanently disable SELinux, modify /etc/selinux/config file and set it as disabled there. Alternatively you can try to modify SELinux to be more permissive, but that's another topic and we shall return to that if this truly was because of SELinux. :-)

EDIT: OK then, SELinux was disabled.

Do you see /tmp/apcphp5.JkKDk7 stylish files appearing under /tmp?

share|improve this answer
    
Thank you for your quick answer Janne! the command /usr/sbin/getenforce returns Disabled –  Jussi Jul 26 '11 at 11:34
    
Edited my reply a bit. –  Janne Pikkarainen Jul 26 '11 at 11:40
    
There are no filenames associated with apcphp in the /tmp when used command ls -la as root. Was wondering this thing earlier on. The folder /tmp had 777 permissions set to it. –  Jussi Jul 26 '11 at 12:00

I had the same problem. It was a tmp problem. Setting mmap_file_mask to /dev/zero got it caching. Details posted on drupal.org under same username.

Setting permissions on tmp does not help if it is not mounted with correct permissions.

share|improve this answer

In case anyone finds this looking for a similar problem, you may need to check for apc.enable_opcode_cache = 1:

"In the development branch (3.1.5dev), an option was introduced to disable the opcode cache (apc.enable_opcode_cache=0), which permits to use Zend OPcache and APC strictly for user data." -Remi Blog

share|improve this answer

Your Answer

 
discard

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.