apc.enabled can be set to 0 to disable APC. This is
primarily useful when APC is statically compiled
into PHP, since there is no other way to disable
it (when compiled as a DSO, the extension
line in php.ini can just be commented-out).
The number of shared memory segments to allocate
for the compiler cache. If APC is running out of
shared memory but you have already set
apc.shm_size as high as your system allows, you
can try raising this value.
The size of each shared memory segment in MB.
By default, some systems (including most BSD
variants) have very low limits on the size of a
shared memory segment.
The optimization level. Zero disables the
optimizer, and higher values use more aggressive
optimizations. Expect very modest speed
improvements. This is experimental.
A "hint" about the number of distinct source files
that will be included or requested on your web
server. Set to zero or omit if you're not sure;
this setting is mainly useful for sites that have
many thousands of source files.
Just like apc.num_files_hint,
a "hint" about the number of distinct user cache variables to store.
Set to zero or omit if not sure.
The number of seconds a cache entry is allowed to
idle in a slot in case this cache entry slot is
needed by another entry. Leaving this at zero
means that your cache could potentially fill up
with stale entries while newer entries won't be
The number of seconds a user cache entry is allowed to idle in a slot in
case this cache entry slot is needed by another entry. Leaving this at
zero means that your cache could potentially fill up with stale entries
while newer entries won't be cached.
The number of seconds that a cache entry may
remain on the garbage-collection list. This value
provides a fail-safe in the event that a server
process dies while executing a cached source file;
if that source file is modified, the memory
allocated for the old version will not be
reclaimed until this TTL reached. Set to zero to
disable this feature.
On by default, but can be set to off and used in
conjunction with positive apc.filters so that files
are only cached if matched by a positive filter.
A comma-separated list of POSIX extended regular
expressions. If any pattern matches the source
filename, the file will not be cached. Note that
the filename used for matching is the one passed
to include/require, not the absolute path. If the
first character of the expression is a + then the
expression will be additive in the sense that any
files matched by the expression will be cached, and
if the first character is a - then anything matched
will not be cached. The - case is the default, so
it can be left off.
If compiled with MMAP support by using --enable-mmap
this is the mktemp-style file_mask to pass to the
mmap module for determing whether your mmap'ed memory
region is going to be file-backed or shared memory
backed. For straight file-backed mmap, set it to
something like /tmp/apc.XXXXXX
(exactly 6 Xs).
To use POSIX-style shm_open/mmap put a .shm
somewhere in your mask. e.g. /apc.shm.XXXXXX
You can also set it to /dev/zero to use your
kernel's /dev/zero interface to anonymous mmap'ed
memory. Leaving it undefined will force an anonymous mmap.
On very busy servers whenever you start the server or
modify files you can create a race of many processes
all trying to cache the same file at the same time.
This option sets the percentage of processes that will
skip trying to cache an uncached file. Or think of it
as the probability of a single process to skip caching.
For example, setting apc.slam_defense
to 75 would mean that there is
a 75% chance that the process will not cache an uncached
file. So, the higher the setting the greater the defense
against cache slams. Setting this to 0
disables this feature.
When you modify a file on a live web server you really
should do so in an atomic manner. That is, write to a
temporary file and rename (mv) the file into its
permanent position when it is ready. Many text editors, cp, tar and
other such programs don't do this. This means that there
is a chance that a file is accessed (and cached) while it
is still being written to. This apc.file_update_protection
setting puts a delay on caching brand new files. The
default is 2 seconds which means that if the modification
timestamp (mtime) on a file shows that it is less than 2
seconds old when it is accessed, it will not be cached.
The unfortunate person who accessed this half-written file
will still see weirdness, but at least it won't persist.
If you are certain you always atomically update your files
by using something like rsync which does this correctly, you
can turn this protection off by setting it to 0. If you
have a system that is flooded with io causing some update
procedure to take longer than 2 seconds, you may want to
increase this a bit.
Mostly for testing and debugging. Setting this enables APC
for the CLI version of PHP. Normally you wouldn't want to
create, populate and tear down the APC cache on every CLI
request, but for various test scenarios it is handy to be
able to enable APC for the CLI version of APC easily.
Prevent files larger than this value from getting cached. Defaults to
Be careful if you change this setting. The default is for this to be On
which means that APC will stat (check) the script on each request to see
if it has been modified. If it has been modified it will recompile and
cache the new version. If you turn this setting off, it will not check.
That means that in order to have changes become active you need to
restart your web server. On a production server where you rarely
change the code, turning stats off can produce a significant performance
For included/required files this option applies as well, but note that
if you are using relative path includes (any path that doesn't start
with / on Unix) APC has to check in order to uniquely identify the file.
If you use absolute path includes APC can skip the stat and use that
absolute path as the unique identifier for the file.
On busy servers when you first start up the server, or when many files
are modified, you can end up with all your processes trying to compile
and cache the same files. With write_lock enabled, only one process at a
time will try to compile an uncached script while the other processes
will run uncached instead of sitting around waiting on a lock.
Logs any scripts that were automatically excluded from being cached due
to early/late binding issues.
Optimize include_once() and require_once()
calls and avoid the expensive system calls used.
RFC1867 File Upload Progress hook handler is only available if you
compiled APC against PHP 5.2.0 or later. When enabled, any file uploads
which includes a field called APC_UPLOAD_PROGRESS
before the file field in an upload form will cause APC to automatically
create an upload_key user cache entry where
key is the value of the
APC_UPLOAD_PROGRESS form entry.
Note that the file upload tracking is not threadsafe at this point, so
new uploads that happen while a previous one is still going will disable
the tracking for the previous.
Example 1. An apc.rfc1867 example
The above example will output
something similar to:
[total] => 1142543
[current] => 1142543
[rate] => 1828068.8
[filename] => test
[name] => file
[temp_filename] => /tmp/php8F
[cancel_upload] => 0
[done] => 1
This enables a lock-free local process shadow-cache which reduces lock
contention when the cache is being written to.
The size of the local process shadow-cache, should be set to a
sufficently large value, approximately half of