• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 How to properly enable memcached and apc?

RoldanLT

Well-known member
#1
This is my config right now:
PHP:
<?php

// Cache
$config['cache']['enabled'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array('caching'  =>  true,
                                            'automatic_serialization' => true,
                                            'lifetime'    => 3600,
                                            'cache_id_prefix'  =>  'phcn_'
);
// MemCache
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
           
            'host' => '127.0.0.1',
            'port' => 11211,
        )
    )
);
// End of Memcache
$config['cache']['backend'] = 'Apc';
But I cannot see it working on my memcache admin:

upload_2014-1-16_16-46-10.png
 

MattW

Well-known member
#3
You don't need to use APC for the backend if you are using Memcache.

Your APC setting is overwriting Memcache, and using APC for the backend cache.

If you want to use Memcache for the backend, and APC as the OPcache, remove the ACP setting, as it will automatically cache the compiled PHP pages, and the backend will be put into Memcache.
 

RoldanLT

Well-known member
#7
Thanks @digitalpoint and @MattW
I change my config to this:
Code:
// Cache
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'phcn_';
$config['cache']['cacheSessions'] = true;


// Memcache
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            'host' => '127.0.0.1',
            'port' => 11211,
        )
    )
);
// End Memcache
But facing a lot of error now :(
I don't know where to fix.
Already restart the server, doesn't fix.
upload_2014-1-16_17-21-39.png
 

RoldanLT

Well-known member
#8
I'm contacting xfrocks about the BD Widget error.
But the error I'm facing on admin "illegal srtring offset" I don't know what's causing this.
 

MattW

Well-known member
#17
Then what line of code should be added into config.php to enable Zend Opcache?
You don't need to. It will cache the PHP pages by default (same as APC if you don't use it for the backend).

This is what I have:

PHP:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
$config['cache']['frontendOptions']['automatic_serialization'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['backend']='Libmemcached';
$config['cache']['backendOptions']=array(
      'compression'=>false,
      'servers' => array(
              array(
                      'host'=>'127.0.0.1',
                      'port'=>'11211',
                      'persistent' => 'true'
                )
      )
);
and just enable zendopcache in the .ini file that centminmod creates

Code:
[root@astra library]# cd /root/centminmod/php.d/
[root@astra php.d]# vim zendopcache.ini

zend_extension=opcache.so
opcache.error_log=/var/log/php_opcache_error.log
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_wasted_percentage=5
opcache.max_accelerated_files=8000
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=0
opcache.save_comments=1
opcache.enable_file_override=1
opcache.validate_timestamps=1