Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP-FPM How to enable PHP APCu on PHP 8.x ?

Discussion in 'Centmin Mod Insights' started by nVidian, Jan 22, 2025.

  1. nVidian

    nVidian Member

    98
    8
    8
    Mar 16, 2015
    Ratings:
    +31
    Local Time:
    4:56 PM
    1.7.9
    5.5
    Hello,

    I mainly serve Drupal sites on my centminmod server, and Drupal suggest that "PHP APCu caching can improve your site's performance considerably. It is highly recommended to have APCu installed on your server."

    1. Does APCu really has benefit on site's performance "considerably" ?
    2. If yes, then how do I enable/setup PHP APCu on PHP 8.x (my current PHP ver is 8.2) ?

    Thank you

     
  2. eva2000

    eva2000 Administrator Staff Member

    54,529
    12,212
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,781
    Local Time:
    7:56 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I'd still with Zend Opcache for opcode caching for for data instead of APCu, I think redis or Memcached server. But Centmin Mod hasn't really kept up with APCu as it really hasn't been used much now that redis and Memcached are around. Centmin Mod removed official APC cache support ages ago.

    But if you want to install APCu with PHP 8.x, you can do it manually, you will need to do this each time you upgrade to a PHP-FPM via centmin.sh menu option 5

    Download APCu from PECL :: Package :: APCu and extract it and compile
    Code (Text):
    cd /svr-setup
    wget https://pecl.php.net/get/apcu-5.1.24.tgz -O apcu-5.1.24.tgz
    tar xzf apcu-5.1.24.tgz
    cd apcu-5.1.24
    phpize
    ./configure --with-php-config=/usr/local/bin/php-config
    make -j$(nproc)
    make install
    

    manually create /etc/centminmod/php.d/apcu.ini with following contents
    Code (Text):
    # php-config --extension-dir
    # https://www.php.net/manual/en/apcu.configuration.php
    extension=apcu.so
    apc.enabled=1
    apc.enable_cli=0
    apc.shm_segments=1
    apc.shm_size="32M"
    apc.entries_hint=8192
    apc.ttl=0
    apc.gc_ttl=3600
    apc.use_request_time=0
    apc.serializer="php"
    

    restart PHP-FPM
    Code (Text):
    fpmrestart

    verify APCu is installed
    Code (Text):
    php --ri apcu

    Note running APCu check via command line will show APCu Support => Disabled as apc.enable_cli=0 is disabled. If you run a phpinfo PHP script from web browser it will show APCu support enabled due to apc.enabled=1
    Code (Text):
    php --ri apcu
    
    apcu
    
    APCu Support => Disabled
    Version => 5.1.24
    APCu Debugging => Disabled
    MMAP Support => Enabled
    MMAP File Mask =>
    Serialization Support => Disabled
    Build Date => Jan 22 2025 18:53:00
    
    Directive => Local Value => Master Value
    apc.enabled => On => On
    apc.shm_segments => 1 => 1
    apc.shm_size => 32M => 32M
    apc.entries_hint => 8192 => 8192
    apc.gc_ttl => 3600 => 3600
    apc.ttl => 0 => 0
    apc.smart => 0 => 0
    apc.mmap_file_mask => no value => no value
    apc.enable_cli => Off => Off
    apc.slam_defense => Off => Off
    apc.preload_path => no value => no value
    apc.coredump_unmap => Off => Off
    apc.use_request_time => Off => Off
    apc.serializer => php => php
    
     
  3. ElChorizo

    ElChorizo Premium Member Premium Member

    53
    5
    8
    Apr 29, 2021
    Ratings:
    +9
    Local Time:
    3:56 AM
    1.19.10
    10.3.28
    I've had redis crash every once in a while over the years. I've been using memcached for like 18 years and I've _never_ seen it crash. I'm a big memcache and zend opcache user/fan. Stick with what works and is tried and true, IMHO.
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,529
    12,212
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,781
    Local Time:
    7:56 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Guess it's depends. I've barely had anything crash in the last decade for any software I install/configure :D
     
  5. ElChorizo

    ElChorizo Premium Member Premium Member

    53
    5
    8
    Apr 29, 2021
    Ratings:
    +9
    Local Time:
    3:56 AM
    1.19.10
    10.3.28
    I've had elastic search servers crash a few times... redis a couple times (we are talking across several servers and multi-dozens of sites).