1. 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?

Discussion in 'XenForo Questions and Support' started by RoldanLT, Jan 16, 2014.

  1. RoldanLT

    RoldanLT Well-Known Member

    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
     
  2. RoldanLT

    RoldanLT Well-Known Member

    But APC works fine with me:
    upload_2014-1-16_16-47-34.png
     
  3. MattW

    MattW Well-Known Member

    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 likes this.
  4. digitalpoint

    digitalpoint Well-Known Member

    Well the last line of your config sets the config back to Apc.
     
    HWS, gfc and RoldanLT like this.
  5. RoldanLT

    RoldanLT Well-Known Member

    I'm confuse how to do this? :)
    You mean APC line?
     
  6. MattW

    MattW Well-Known Member

    Yes, remove the APC line from your config.
     
  7. RoldanLT

    RoldanLT Well-Known Member

    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
     
  8. RoldanLT

    RoldanLT Well-Known Member

    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.
     
  9. MattW

    MattW Well-Known Member

    What does the memcache section of phpinfo say?
     
  10. RoldanLT

    RoldanLT Well-Known Member

  11. Null

    Null Well-Known Member

    Just letting you know, you don't need APC if you're running 5.5.x.
     
    RoldanLT likes this.
  12. MattW

    MattW Well-Known Member

    You are running Libmemcached.

    Change your config to this:

    PHP:
    $config['cache']['backend']='Libmemcached';
     
    RoldanLT likes this.
  13. RoldanLT

    RoldanLT Well-Known Member

    Yes, I'm using php 5.5.7.
    But I don't enable zend opcache, is it worth it to enable it?
     
  14. MattW

    MattW Well-Known Member

    Yes, I swapped out to Zend Opcache when I moved to 5.5.X
     
    RoldanLT likes this.
  15. RoldanLT

    RoldanLT Well-Known Member

    Thanks @MattW didn't know it's different.
     
  16. RoldanLT

    RoldanLT Well-Known Member

    Then what line of code should be added into config.php to enable Zend Opcache?
     
  17. MattW

    MattW Well-Known Member

    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
     
    SneakyDave, melbo and RoldanLT like this.
  18. RoldanLT

    RoldanLT Well-Known Member

    When I enable: $config['cache']['frontendOptions']['automatic_serialization'] = true;
    I got an error:
    upload_2014-1-16_17-58-11.png
     
  19. MattW

    MattW Well-Known Member

    Just remove that line then, you might not need it. It was in mine from when I had Xcache installed.
     
  20. RoldanLT

    RoldanLT Well-Known Member

    Already fixed this by restarting memcache.
     
    MattW likes this.

Share This Page