7

On my new Xubuntubox I installed the lamp-server tools, php, php-apc, added the extension=apc.so line to the php.ini and rebootet the system. Apache and PHP seem to work well, but APC doesn't.

So I checked what the apc.php file would say:

No cache info available. APC does not appear to be running.

But in the php info it seems to be enabled. Have a look what php -i | grep 'apc' says:

Additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
apc
apc.cache_by_default => On => On
apc.canonicalize => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On             <- it is enabled
apc.file_md5 => Off => Off
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.lazy_classes => Off => Off
apc.lazy_functions => Off => Off
apc.max_file_size => 1M => 1M
apc.mmap_file_mask => no value => no value
apc.num_files_hint => 1000 => 1000
apc.preload_path => no value => no value
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => default => default
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 0 => 0
apc.write_lock => On => On

As expected php -m | grep 'apc' also finds apc.

Do you know what is missing, that I can't use it correctly?

erikbstack
  • 12,878
  • 21
  • 81
  • 115
  • 2
    Make sure you gave APC enough ram, 32M is very low (just enough fo one Wordpress site). Check my answer there to know how to configure APC http://stackoverflow.com/questions/3723316/warning-require-once-function-require-once-unable-to-allocate-memory-for-p – bokan Aug 29 '12 at 14:44

1 Answers1

9

There are two ways to run PHP.

You are showing the CLI configuration for PHP, and apc.php is not using it.

Indeed, if you check phpinfo() through your browser, you can see that no APC extension is loaded.

The solution : Open at /etc/php5/cgi/conf.d/apc.ini (cgi not cli) and paste your configuration there, again. Restart the web server (sudo service httpd restart) and voilà !

Hope this helps !

Justin T.
  • 3,643
  • 1
  • 22
  • 43
  • ah, okay. I thought that the automatically generated `/etc/php5/apache2/conf.d/apc.ini` would be enough. With the `.../cgi/...` folder it works with apache, now. The funny thing is that cli still doesn't work. – erikbstack May 23 '12 at 09:12
  • 7
    okay, for cli I just need to add another line to the `/etc/php5/cli/conf.d/apc.ini` that says `apc.enable_cli=1` – erikbstack May 23 '12 at 09:18
  • My server also says APC enabled but find / -name apc.ini does not show that I have a apc.ini file anywhere. – DevKev Oct 02 '13 at 14:07
  • 2
    For PHP 5.5 https://bugs.php.net/bug.php?id=65731 "APC doesn't support PHP 5.5. PHP 5.5 comes bundled with an opcode cache now." – hardik Jan 16 '14 at 14:12