I installed NextCloud and in the summary window it keeps telling me that my OPCache is not enabled. I have enabled it and I am seeing conflicting information about if it really is enabled or not.
Ubuntu 18.04.1 | PHP 7.2.11-2
$ sudo cat /etc/php/7.2/apache2/php.ini | grep opcache
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
;opcache.validate_timestamps=1
opcache.revalidate_freq=1
;opcache.revalidate_path=0
opcache.save_comments=1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
;opcache.restrict_api=
;opcache.mmap_base=
;opcache.file_cache=
;opcache.file_cache_only=0
;opcache.file_cache_consistency_checks=1
; Implies opcache.file_cache_only=1 for a certain process that failed to
;opcache.file_cache_fallback=1
;opcache.huge_code_pages=1
;opcache.validate_permission=0
;opcache.validate_root=0
;opcache.opt_debug_level=0
Here is my output of php -i:
$ php -i
Zend OPcache
Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI
Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On
Then finally, looking at a phpinfo() generated page, I see it loading the php.ini file from the correct one I have edited from the first block. The only additional .ini file it is loading is from the mods-available folder:
$ sudo cat /etc/php/7.2/mods-available/opcache.ini
; configuration for php opcache module
; priority=10
zend_extension=/usr/lib/php/20170718/opcache.so
There isn't any of the settings in that file, so the only file I see those settings in is the php.ini file, which is the same one being loaded from phpinfo(). These settings have been set for a while too, I am just now noticing they weren't taking affect. So the apache server has been rebooted with these settings saved. What am I missing here?
Edit:
Here are some screenshots of the phpinfo() screen for further clarification:
Well after playing around for a few hours, I think I figured it out. In par with what #Sammitch said. When I was doing an apt-get update, it was installing 7.3 php files for some reason. So I purged those and verified my config for php was set to default to 7.2 and then did another update and autoremove. That seemed to clear that confusion up. Not sure how that happened though.
Related
I'm trying to enable opcode cache for PHP and make sure that its working for served pages. I'm currently running an Apache 2.4.52 server on an Amazon EC2 instance. I know for sure that opcode cache is installed, and I have a file 10-opcache.ini in php.d, which is where all other ini files are read from. The problem is that 10-opcache.ini doesn't seem to be getting read when I call phpinfo() in a served page, but it is being read when I call phpinfo() in the command line.
Here is my output for the first section of phpinfo() ran through the command line:
Interactive shell
php > phpinfo();
phpinfo()
PHP Version => 7.2.34
System => Linux ip-172-31-84-175.ec2.internal 5.10.82-83.359.amzn2.x86_64 #1 SMP Tue Nov 30 20:47:14 UTC 2021 x86_64
Build Date => Oct 21 2020 18:03:14
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
Additional .ini files parsed => /etc/php.d/10-opcache.ini,
/etc/php.d/20-bz2.ini,
/etc/php.d/20-calendar.ini,
/etc/php.d/20-ctype.ini,
/etc/php.d/20-exif.ini,
/etc/php.d/20-fileinfo.ini,
/etc/php.d/20-ftp.ini,
/etc/php.d/20-gettext.ini,
/etc/php.d/20-iconv.ini,
/etc/php.d/20-json.ini,
/etc/php.d/20-mbstring.ini,
/etc/php.d/20-mysqlnd.ini,
/etc/php.d/20-pdo.ini,
/etc/php.d/20-phar.ini,
/etc/php.d/20-sockets.ini,
/etc/php.d/20-sqlite3.ini,
/etc/php.d/20-tokenizer.ini,
/etc/php.d/20-zip.ini,
/etc/php.d/25-curl.ini,
/etc/php.d/30-mysqli.ini,
/etc/php.d/30-pdo_mysql.ini,
/etc/php.d/30-pdo_sqlite.ini
PHP API => 20170718
PHP Extension => 20170718
Zend Extension => 320170718
Zend Extension Build => API320170718,NTS
PHP Extension Build => API20170718,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => available, disabled
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
phpinfo() command line section for Zend opcache
Opcode Caching => Up and Running
Optimization => Enabled
SHM Cache => Enabled
File Cache => Disabled
Startup => OK
Shared memory model => mmap
Cache hits => 0
Cache misses => 0
Used memory => 18272040
Free memory => 115945688
Wasted memory => 0
Interned Strings Used memory => 197992
Interned Strings Free memory => 8190616
Cached scripts => 0
Cached keys => 0
Max keys => 7963
OOM restarts => 0
Hash keys restarts => 0
Manual restarts => 0
Directive => Local Value => Master Value
opcache.blacklist_filename => /etc/php.d/opcache*.blacklist => /etc/php.d/opcache*.blacklist
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => On => On
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 4000 => 4000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On
Here are my basic configuration settings for opcode cache in 10-opcache.ini
; Enable Zend OPcache extension module
zend_extension=opcache
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=4000
; The maximum percentage of "wasted" memory until a restart is scheduled.
;opcache.max_wasted_percentage=5
; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
opcache.use_cwd=1
Here is what happens when I call phpinfo() in a served page:
phpinfo page
Here's a list of the parsed .ini files if you don't want to look at the screenshot.
/etc/php.d/20-bz2.ini, /etc/php.d/20-calendar.ini, /etc/php.d/20-ctype.ini, /etc/php.d/20-exif.ini, /etc/php.d/20-fileinfo.ini, /etc/php.d/20-ftp.ini, /etc/php.d/20-gettext.ini, /etc/php.d/20-iconv.ini, /etc/php.d/20-json.ini, /etc/php.d/20-mbstring.ini, /etc/php.d/20-mysqlnd.ini, /etc/php.d/20-pdo.ini, /etc/php.d/20-phar.ini, /etc/php.d/20-sockets.ini, /etc/php.d/20-sqlite3.ini, /etc/php.d/20-tokenizer.ini, /etc/php.d/20-zip.ini, /etc/php.d/25-curl.ini, /etc/php.d/30-mysqli.ini, /etc/php.d/30-pdo_mysql.ini, /etc/php.d/30-pdo_sqlite.ini
The 10-opcache.ini isn't appearing on the list of parsed files. So I'm worried that opcache isn't working correctly. Looking at other posts related to this topic, 10-opcache.ini should be appearing in served pages.
I have Xdebug enabled and working together with OPcache. OPcache module is loaded first by phpfpm (important). If you try to debug the code below (from the browser) and put a breakpoing in the local variables you will see that they are not displayed. If I deactivate OPCache everything works as expected. I'm using PhpStorm 2018.2.5 to debug.
class Foo {
public $member = 'Some value';
public function methodFoo() {
$localFoo = "local2";
}
}
class Bar {
public $firstMember = "foo";
public $secondMember = "bar";
public function create() {
$localBar = 10;
$newFoo = new Foo();
$newFoo->methodFoo();
$localBar += 1;
$this->firstMember = "Other value";
}
}
$foo = "testing";
$bar = "testing2";
$obj = new Bar();
$obj->create();
I do not know if I miss something or it's a bug. Years ago there was a similar bug in xdebug but it was not related to OPcache:
bug
I leave the information related to my system and the log of Xdebug
phpinfo()
PHP Version => 7.2.10-0ubuntu0.18.04.1
System => Linux pablo-dv6 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64
Build Date => Sep 13 2018 13:45:02
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini
Scan this dir for additional .ini files => /etc/php/7.2/cli/conf.d
Additional .ini files parsed => /etc/php/7.2/cli/conf.d/10-opcache.ini,
/etc/php/7.2/cli/conf.d/10-pdo.ini,
/etc/php/7.2/cli/conf.d/15-xml.ini,
/etc/php/7.2/cli/conf.d/20-calendar.ini,
/etc/php/7.2/cli/conf.d/20-ctype.ini,
/etc/php/7.2/cli/conf.d/20-curl.ini,
/etc/php/7.2/cli/conf.d/20-dom.ini,
/etc/php/7.2/cli/conf.d/20-exif.ini,
/etc/php/7.2/cli/conf.d/20-fileinfo.ini,
/etc/php/7.2/cli/conf.d/20-ftp.ini,
/etc/php/7.2/cli/conf.d/20-gettext.ini,
/etc/php/7.2/cli/conf.d/20-iconv.ini,
/etc/php/7.2/cli/conf.d/20-intl.ini,
/etc/php/7.2/cli/conf.d/20-json.ini,
/etc/php/7.2/cli/conf.d/20-mbstring.ini,
/etc/php/7.2/cli/conf.d/20-pdo_sqlite.ini,
/etc/php/7.2/cli/conf.d/20-phar.ini,
/etc/php/7.2/cli/conf.d/20-posix.ini,
/etc/php/7.2/cli/conf.d/20-readline.ini,
/etc/php/7.2/cli/conf.d/20-shmop.ini,
/etc/php/7.2/cli/conf.d/20-simplexml.ini,
/etc/php/7.2/cli/conf.d/20-sockets.ini,
/etc/php/7.2/cli/conf.d/20-sqlite3.ini,
/etc/php/7.2/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.2/cli/conf.d/20-sysvsem.ini,
/etc/php/7.2/cli/conf.d/20-sysvshm.ini,
/etc/php/7.2/cli/conf.d/20-tokenizer.ini,
/etc/php/7.2/cli/conf.d/20-wddx.ini,
/etc/php/7.2/cli/conf.d/20-xmlreader.ini,
/etc/php/7.2/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.2/cli/conf.d/20-xsl.ini,
/etc/php/7.2/cli/conf.d/20-zip.ini,
/etc/php/7.2/cli/conf.d/30-xdebug.ini
PHP API => 20170718
PHP Extension => 20170718
Zend Extension => 320170718
Zend Extension Build => API320170718,NTS
PHP Extension Build => API20170718,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => available, disabled
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, convert.iconv.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
Zend OPcache
Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
Startup Failed => Opcode Caching is disabled for CLI
Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On
Xdebug log related to this part (you can see that $localBar doesn't appear):
<- context_get -i 46 -d 0 -c 0
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="46" context="0"><property name="$newFoo" fullname="$newFoo" type="uninitialized"></property><property name="$this" fullname="$this" type="object" classname="Bar" children="1" numchildren="2" page="0" pagesize="100"><property name="firstMember" fullname="$this->firstMember" facet="public" type="string" size="3" encoding="base64"><![CDATA[Zm9v]]></property><property name="secondMember" fullname="$this->secondMember" facet="public" type="string" size="3" encoding="base64"><![CDATA[YmFy]]></property></property></response>
Any help is welcome, thanks :)
I answer myself, in case it serves to someone.
This is a feature of OPCache. It optimizes PHP code by sometimes removing variables if they are not needed.
Solution: disable OPCache when debugging.
sudo phpdismod opcache
And restart phpfpm or apache according to your environment
sudo service php7.2-fpm restart
or
sudo service apache2 restart
More info here.
It's a late answer, but the accepted one is not entirely correct. The problem is not that you cannot use OPCache with xdebug. You can, but you have to load the OPCache extension BEFORE xdebug. To quote the documentation:
If you want to use Xdebug and OPCache together, you must have the
zend_extension line for Xdebug below the line for OPCache, or in a
file starting with a higher number (ie. 99-xdebug.ini vs
20-opcache.ini), otherwise they won't work properly together.
So I get this famous error while try to run shell script (through browser is working without issues)
Fatal error: Uncaught CacheException: Cache engine "default" is not
properly configured.
default is pointing to Apc cache.
Cache::config('default', array(
'engine' => 'Apc',
'prefix' => 'some_default',
'duration' => '+1 hour'
));
Stack trace:
#0 /.../lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('default')
#1 /.../app/Config/core.php(381): Cache::config('default', Array)
#2 /.../lib/Cake/Core/Configure.php(72): include('/home/...')
#3 /.../lib/Cake/bootstrap.php(432): Configure::bootstrap(true)
#4 /.../lib/Cake/Console/ShellDispatcher.php(145): require('/home/...')
#5 /.../lib/Cake/Console/ShellDispatcher.php(100): ShellDispatcher->_bootstrap()
#6 /.../lib/Cake/Console/ShellDispatcher.php(54): ShellDispatcher->_initEnvironment()
#7 /home/ in /.../lib/Cake/Cache/Cache.php on line 186
Environment:
Apache/2.4.18 (Ubuntu)
PHP 7.0.13-0ubuntu0.16.04.1 (cli)
CakePHP v2.8.0
php -i | grep apc:
apc.coredump_unmap => Off => Off
apc.enable_cli => On => On
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.writable => /tmp => /tmp
Cake tmp folder - permissions 777 owned by www-data user (which run apache also)
tmp contains /cache, tmp/cache/models, tmp/cache/persistent and tmp/logs with the same permission as tmp.
If I change default engine from Apc to Redis for example, everything works without issues.
Apc for php7.0 is deprecated, so you need install apcu and than apcu-bc - for compatibility with apc.
Maybe is only in my case but when i put in .../cli/php.ini those lines
extension=apcu.so
extension=apc.so
apcu.enabled=1
apc.enable_cli=1
Apc still not work, i got warnings:
default cache was unable to write 'key' to Apc cache
It start to work when i create two files
.../cli/config.d/apcu.ini which contains:
extension=apcu.so
and .../cli/config.d/z_apc.ini which contains:
extension=apc.so
apc.enable_cli=1
(z prefix is for order, apc should be loaded after apcu)
I've got to be missing something obvious. My APC is installed correctly and showing up in phpinfo() just fine. I'm currently running php 5.4.20 with APC 3.1.13 on apache. It is a cpanel install so keep that in mind as well.
The main problem is that the cache is working, but only for the duration of the page load. if I run
<?php
apc_store('foo', 'bar');
echo apc_fetch('foo');
?>
It will echo out the variable, but if I comment out apc_store and run the code again, nothing shows up and var_dump shows boolean(false);
I've tried this code also in case I was doing something dumb, and this does not work also. It always shows "str not found from cache...saving"
// Check if str found from cache
if (apc_exists('str')) {
// Print str from cache
echo "str from cache: ", apc_fetch('str'), "<br />";
// Clear cache
apc_clear_cache('user');
// Try to fetch str again
echo "str from cache, after user cache is cleared: ", "<br />";
var_dump(apc_fetch('str'));
}
else {
// Save str to cache and set ttl 120 seconds
echo 'str not found from cache...saving', "<br />";
$str = "This is just test";
apc_store('str', $str, 120);
}
My apc config is as follows...
apc
APC Support => disabled
Version => 3.1.13
APC Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>
Locking type => pthread read/write Locks
Serialization Support => broken
Revision => $Revision: 327136 $
Build Date => Oct 17 2013 16:47:57
Directive => Local Value => Master Value
apc.cache_by_default => Off => Off
apc.canonicalize => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
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 => 512 => 512
apc.shm_strings_buffer => 4M => 4M
apc.slam_defense => Off => Off
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
I must be missing something obvious..... any help is appreciated. TIA
EDIT
So I checked to see if it apc was working properly on the prod server that has apc already installed on it. It in fact is working as it should be. So I ran php_sapi_name() and on the prod server it is apache2handler and on the dev server (the one I'm currently working with), it is using cgi-fcgi, which is probably the cause for the problem. Since I'm using cPanel I should be able to simply change the PHP "Handler" from suPHP to maybe DSO and it should work after that. The prod server doesn't use cpanel, just good old fashion....er.....non-cPanel stuff to make it work.
You'll need to use the APC web interface to debug this issue.
Find a file called apc.php
find / -name apc.php
Now copy this to you www/ folder and load it up in the browser.
(Here's an example of what it looks like: http://andrewdunkle.com/apc.php )
Now, retry your script and check that the variable has been stored properly and has a long expiry date.
Also test to see if the system cache appears to get reset on each page load. (APC.php or your other scripts.)
Finally, try switching from worker to prefork in apache. (Or the other way around if you use prefork)
I found this thread that answered my question. The root problem was that I was running under CGI-FCGI when I needed be be under DSO/mod_php to run APC properly. Changing that on Cpanel was a beast because the apc.so extension caused the part when you change the php handler to fail....yar.
I've installed libmemcached and memcached pecl extension for php and for some reason it's not installing correctly? i've got memcached.so in /usr/lib64/php/ with the right permissions and libmemcache.so in /usr/local/lib/
Everything seemed to build correctly without error, and I restarted apache?
i also have the daemon installed.
I somehow easily got the Memcache class easily installed for php before, but I realized what i wanted was the Memcached (note the d) class. let me know if more info is needed!
EDIT: I previously had memcache (without the d) working in php so I know i was manipulating the correct php.ini!
EDIT 2: there WAS indeed an apache error!
Unable to load dynamic library '/usr/lib64/php/modules/memcached.so' - /usr/lib64/php/modules/memcached.so: undefined symbol: php_json_encode in Unknown on line 0
I've solved it in centos5 using the yum installer instead of the pecl install memcached
THIS way --> yum install php-pecl-memcached
then, service httpd restart and it shows up in phpinfo()
I have the similar error few days ago. Instaling of new version(2.0) of memcached helped me.
yum -y install gcc-c++
wget http://launchpad.net/libmemcached/1.0/0.50/+download/libmemcached-0.50.tar.gz
tar xzf libmemcached-0.50.tar.gz
cd libmemcached-0.50
./configure
make
make install
wget http://pecl.php.net/get/memcached-2.0.0b2.tgz
pecl install memcached-2.0.0b2.tgz
echo 'extension=memcached.so' > /etc/php.d/memcached.ini
service php-fpm restart
cd ..
rm -r libmemcached-0.50*
rm -r memcached-
I don't know if it's the same problem but after struggling with this for hours I manage to have PHP properly installed with Memcached on CentOS using the command bellow:
yum --enablerepo=remi-php73 install php-memcached
Test installation:
php -i | grep -i memcache
Should show something like:
/etc/php.d/50-memcached.ini
memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.default_binary_protocol => Off => Off
memcached.default_connect_timeout => 0 => 0
memcached.default_consistent_hash => Off => Off
memcached.serializer => igbinary => igbinary
memcached.sess_binary_protocol => On => On
memcached.sess_connect_timeout => 0 => 0
memcached.sess_consistent_hash => On => On
memcached.sess_consistent_hash_type => ketama => ketama
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => not set => not set
memcached.sess_lock_retries => 5 => 5
memcached.sess_lock_wait => not set => not set
memcached.sess_lock_wait_max => 150 => 150
memcached.sess_lock_wait_min => 150 => 150
memcached.sess_locking => On => On
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_persistent => Off => Off
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => Off => Off
memcached.sess_remove_failed_servers => Off => Off
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.sess_server_failure_limit => 0 => 0
memcached.store_retry_count => 2 => 2
Registered save handlers => files user memcached
add
extension=memcache.so
in php.ini then restart apache