How to Limit APC Caching to Specific Virtual Sites

nano /etc/php.d/apc.iniInside the ini file locate the apc.filter variable and set it to the following:

apc.filter = ".*,+/home/user/public_html/.*"
Save apc.ini and restart php-fpm
service php-fpm restart
What the setting did was it enabled the filter which skips all php files (.*) that apc is supposed to cache. Then by defining (+/home/user/public_html/.*) apc will cache all php files under the directory. By doing it this way you can enable PHP APC to a select sites that you need cached. As far as my experience goes, each WordPress site uses about ~20 MB of APC cache memory (will likely vary depending on your WordPress site, plugins installed etc.) so if you use the default apc.shm_size which is 32 MB, you can safely cache at least one WordPress site. The reason I don’t recommend going for two sites based on the figures above is because you need to have a good amount of spare cache memory to prevent fragmentation. I usually go for 10% to 20% of free memory, the more, the better. Some things you should know.
web-server: nginx 1.2.7
php: php-fpm 5.4.7
apc: php apc 3.1.13
db: mysql 5.5.28
 ]]>