title: APC is behaving weirdly in combination with PHP5-FPM and Nginx
body: <p>I've got APC running on my Ubuntu 13.04 Server box for quite a while now. A couple of days ago, something, somewhere went wrong and now it's acting very strangely. I'll lay it out.</p>
  
  <ul>
  <li>APC 3.1.13 (<a href="http://vps.sparrowinspace.com/apc.php" rel="nofollow">http://vps.sparrowinspace.com/apc.php</a>)</li>
  <li>PHP 5.4.9 (<a href="http://vps.sparrowinspace.com/phpinfo.php" rel="nofollow">http://vps.sparrowinspace.com/phpinfo.php</a>)</li>
  <li>Nginx 1.4.1</li>
  </ul>
  
  <p>My PHP configuration files are in <code>/etc/php5/mods-available</code>. All of the configuration directories of PHP5 (<code>/etc/php5/cli/conf.d</code>, <code>/etc/php5/fpm/conf.d</code>, etc.) are symlinked to <code>/etc/php5/conf.d/</code> which in turn is symlinked to <code>/etc/php5/mods-available</code>. If I run <code>php -i</code> from a shell I get the config files for <code>/etc/php5/cli/conf.d/*</code> returned, which should be exactly the same as config files anywhere. The relevant part for my question would be this:</p>
  
  <pre><code>apc
  
  APC Support =&gt; disabled
  Version =&gt; 3.1.13
  APC Debugging =&gt; Disabled
  MMAP Support =&gt; Enabled
  MMAP File Mask =&gt; /tmp/apc.XXXXXX
  Locking type =&gt; pthread mutex Locks
  Serialization Support =&gt; broken
  Revision =&gt; $Revision: 327136 $
  Build Date =&gt; Oct  9 2012 20:29:11
  
  Directive =&gt; Local Value =&gt; Master Value
  apc.cache_by_default =&gt; On =&gt; On
  apc.canonicalize =&gt; On =&gt; On
  apc.coredump_unmap =&gt; Off =&gt; Off
  apc.enable_cli =&gt; Off =&gt; Off
  apc.enabled =&gt; On =&gt; On
  apc.file_md5 =&gt; Off =&gt; Off
  apc.file_update_protection =&gt; 2 =&gt; 2
  apc.filters =&gt; no value =&gt; no value
  apc.gc_ttl =&gt; 3600 =&gt; 3600
  apc.include_once_override =&gt; Off =&gt; Off
  apc.lazy_classes =&gt; Off =&gt; Off
  apc.lazy_functions =&gt; Off =&gt; Off
  apc.max_file_size =&gt; 1M =&gt; 1M
  apc.mmap_file_mask =&gt; /tmp/apc.XXXXXX =&gt; /tmp/apc.XXXXXX
  apc.num_files_hint =&gt; 512 =&gt; 512
  apc.preload_path =&gt; no value =&gt; no value
  apc.report_autofilter =&gt; Off =&gt; Off
  apc.rfc1867 =&gt; Off =&gt; Off
  apc.rfc1867_freq =&gt; 0 =&gt; 0
  apc.rfc1867_name =&gt; APC_UPLOAD_PROGRESS =&gt; APC_UPLOAD_PROGRESS
  apc.rfc1867_prefix =&gt; upload_ =&gt; upload_
  apc.rfc1867_ttl =&gt; 3600 =&gt; 3600
  apc.serializer =&gt; default =&gt; default
  apc.shm_segments =&gt; 1 =&gt; 1
  apc.shm_size =&gt; 128M =&gt; 128M
  apc.shm_strings_buffer =&gt; 4M =&gt; 4M
  apc.slam_defense =&gt; On =&gt; On
  apc.stat =&gt; On =&gt; On
  apc.stat_ctime =&gt; Off =&gt; Off
  apc.ttl =&gt; 3600 =&gt; 3600
  apc.use_request_time =&gt; On =&gt; On
  apc.user_entries_hint =&gt; 4096 =&gt; 4096
  apc.user_ttl =&gt; 7200 =&gt; 7200
  apc.write_lock =&gt; On =&gt; On
  </code></pre>
  
  <p>This shows the option <code>apc.enabled</code> as On. However, my phpinfo.php (link above), which shows the configuration for PHP5-FPM (from <code>/etc/php5/fpm/conf.d</code>) shows this option as Off. Thing is, the commandline version of php (cli) and the version that runs on my webserver (fpm) use the exact same symlinked configuration files.</p>
  
  <p>My APC seems to be caching, but it behaves strangely. Before when I emptied the cache and reloaded some pages on the Wordpress installs on my server I would see pages get cached right away. Now, it's stuck on the same Hits and Misses numbers for hours, and I can refresh as much as I want, nothing changes. </p>
  
  <p>The <code>apc.enabled</code> option shows as <code>0</code> (Off) on <code>apc.php</code> as well, but it seems to be doing at least something. There're files in the opcode cache as well as in the usercache. It's behaving strangely and I'm getting a lot of contradicting settings returned from PHP. I'm at a loss here. Here's <code>20-apc.ini</code> for good measure:</p>
  
  <pre><code>extension=apc.so
  apc.enabled="1"
  apc.stat = "1"
  apc.max_file_size = "1M"
  apc.localcache = "1"
  apc.localcache.size = "128"
  apc.shm_segments = "1"
  apc.ttl = "3600"
  apc.user_ttl = "7200"
  apc.gc_ttl = "3600"
  apc.cache_by_default = "1"
  apc.filters = ""
  apc.write_lock = "1"
  apc.num_files_hint= "512"
  apc.user_entries_hint="4096"
  apc.shm_size = "128M"
  apc.mmap_file_mask=/tmp/apc.XXXXXX
  apc.include_once_override = "0"
  apc.file_update_protection="2"
  apc.canonicalize = "1"
  apc.report_autofilter="0"
  apc.stat_ctime="0"
  </code></pre>
  
  <p>If someone needs any other config files or part of them, I'm keeping an eye on this thread, please tell me.</p>