Learn about Centmin Mod LEMP Stack today
Become a Member

PHP-FPM Caching Questions

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by RPGX, Jul 19, 2016.

  1. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    Hello!

    First of all, thanks for this great package.

    I have a question about the opcode caches. I am running modified forum code (currently vBulletin, but transitioning away from that) with user-specific information shown (or not shown) on pages, and ran into problems in the past using caching agents that attached themselves to individual workers. I also need to be able to clear all the cache reliably all at once. Because of some headaches, the only caching I currently use is a file system cache.

    Do I have anything to worry about with the default APC caching option that you have set up for php 5.6 (my current upgrade target)?

    Thank you!

    EDIT: to be clear, it is very important for me that all processes share the same information.
     
    Last edited: Jul 19, 2016
  2. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    FYI, APC Cache is no longer top dog. You'd probably want to use Zend Opcache for php opcode caching and for vB datastore caching use memcached server and you'll be fine :)

    PHP 5.6 has native Zend Opcache support so if you update via centmin.sh menu option 5, at prompt answer yes to Zend Opcache :)

    Also see PHP Opcode and Memcached statistics pages | Centmin Mod Community
     
  3. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    Thank you for the advice.

    I went ahead and installed Zend and memcached.

    php -i |grep Zend
    Zend Extension => 220131226
    Zend Extension Build => API220131226,NTS
    Zend Signal Handling => disabled
    Zend Memory Manager => enabled
    ...

    php -i | grep memcached
    /etc/centminmod/php.d/memcached.ini,
    memcached
    memcached support => enabled
    libmemcached version => 1.0.18
    ...


    I tried to look at the admin files you mention here: PHP Opcode and Memcached statistics pages | Centmin Mod Community

    I had some issues:
    1) The Zend one (ending _opcache.php) is created with install, but when I try to open it in a browser I get a blank page (after entering the user/pass information provided) that times out after several minutes (502 error). Does this admin page usually take so long to load? Do I need to set a longer timeout? I can browse other files in that folder e.g. index.html.
    2) The memcached file is not installed with memcached in /usr/local/nginx/html/ -- there is no memcache_${N}.php file created (there is also no login/password info in any logs at /root/centminlogs/) There *is* an old file in there called 'memcache.php' from 2014, but I don't think that's what I'm after.

    I tried echo stats | nc 127.0.0.1 11211 as suggesting, and see:
    STAT pid 19057
    STAT uptime 1020
    STAT time 1468946786
    STAT version 1.4.4
    STAT pointer_size 64
    STAT rusage_user 1.414784
    STAT rusage_system 3.505467
    STAT curr_connections 15
    STAT total_connections 23
    STAT connection_structures 16
    STAT cmd_get 187550
    STAT cmd_set 80221
    STAT cmd_flush 0
    STAT get_hits 185637
    STAT get_misses 1913
    STAT delete_misses 0
    STAT delete_hits 0
    STAT incr_misses 0
    STAT incr_hits 0
    STAT decr_misses 0
    STAT decr_hits 0
    STAT cas_misses 0
    STAT cas_hits 0
    STAT cas_badval 0
    STAT auth_cmds 0
    STAT auth_errors 0
    STAT bytes_read 11032020
    STAT bytes_written 657178318
    STAT limit_maxbytes 67108864
    STAT accepting_conns 1
    STAT listen_disabled_num 0
    STAT threads 4
    STAT conn_yields 0
    STAT bytes 855750
    STAT curr_items 402
    STAT total_items 80221
    STAT evictions 0
    END

    Help :) I would like to be able to see the admin information to make sure that caches are operating as expected.
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    What version of centmin mod you using ? when was it last updated ?

    centmin.sh menu option 10 to reinstall memcached server/ and related php extensions see if that helps

    Upgrading Centmin Mod Code to Latest Version



    Getting Started Guide step 19 outlines also how to keep Centmin Mod code updated or how to switch version branches.

    Centmin Mod LEMP stack's script code is constantly updated for improvements, bug fixes and security fixes so keeping the Centmin Mod code up to date is important. With Centmin Mod 1.2.3-eva2000.08) (123.08stable) and higher releases, a newly added centmin.sh menu option 23 allows much easier code updates and version branch swicthing via Git backed environment you can setup. For full details read the following links:
    Upgrading Centmin Mod involves 2 parts.
    1. Upgrading the actual Centmin Mod code outlined at Upgrade Centmin Mod. This is heart of Centmin Mod where the code is the engine that runs centmin.sh shell based menu and all the automation you're accustomed to. You can easily update within a Centmin Mod version branch or switch version branches via centmin.sh menu option 23 outlined here.
    2. Upgrade software that Centmin Mod installed or manages. For this part following outline at How to upgrade Centmin Mod software installed on your server.
    So essentially, you can upgrade from .07 to .08 in place, but not everything is upgraded as some things like server initial environment setup isn't changed i.e. how swap, tmp setup and allocation are created etc. The main parts from part 2 above are what in place upgrades do i.e. Nginx and PHP-FPM compilation and config/settings parameters and MariaDB version from 5.5 to 10.0.x. If you want the full environment changed including tmp and swap setup to .08's configuration, then you would need a fresh OS install and fresh .08 initial install. You can think of it like upgrading Windows 7 to Windows 8. An in place upgrade will upgrade code but won't change your computer environment from when you installed Windows 7 i.e. disk configuration and partition sizes won't change from when you initially installed Windows 7. Only way to change that would be fresh Windows 8 install.
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    if centmin.sh menu option 10 doesn't create the memcached stats file you can do it manually using these commands in SSH

    just define the memcache php extension version installed via MEMCACHE_VERSION variable MEMCACHE_VERSION=3.0.8
    Code (Text):
    MEMCACHE_VERSION=3.0.8
    cd /svr-setup/memcache-${MEMCACHE_VERSION}
    N=$(od -vAn -N4 -tx < /dev/urandom)
    N=$(echo ${N} | sed -e 's/\s//')
    \cp -a memcache.php /usr/local/nginx/html/memcache_${N}.php
    chown -R nginx:nginx /usr/local/nginx/html
    chmod 644 /usr/local/nginx/html/memcache_${N}.php
    sed -i "s/'ADMIN_USERNAME','memcache'/'ADMIN_USERNAME','memcacheuser'/g" /usr/local/nginx/html/memcache_${N}.php
    sed -i "s/'ADMIN_PASSWORD','password'/'ADMIN_PASSWORD','memcachepass'/g" /usr/local/nginx/html/memcache_${N}.php
    sed -i "s/mymemcache-server1:11211/localhost:11211/g" /usr/local/nginx/html/memcache_${N}.php
    sed -i "s/\$MEMCACHE_SERVERS\[] = 'mymemcache-server2:11211'; \/\/ add more as an array/\/\/ mymemcache-server2:/g" /usr/local/nginx/html/memcache_${N}.php
    CSALT=$(openssl rand -hex 5)
    memcacheduser=$(echo "memadmin${CSALT}")
    memcachedpassword=$(openssl rand -hex 12)
    sed -i "s/'ADMIN_USERNAME','memcacheuser'/'ADMIN_USERNAME','${memcacheduser}'/g" /usr/local/nginx/html/memcache_${N}.php 2>&1>/dev/null
    sed -i "s/'ADMIN_PASSWORD','memcachepass'/'ADMIN_PASSWORD','${memcachedpassword}'/g" /usr/local/nginx/html/memcache_${N}.php 2>&1>/dev/null
    echo "Memcached Server Admin Login: /usr/local/nginx/html/memcache_${N}.php"
    echo "new memcached username: ${memcacheduser}"
    echo "new memcached password: ${memcachedpassword}"
    
     
  6. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    version: 1.2.3-eva2000.08

    Unless these cron jobs are failing silently, it is updated regularly:
    0 */4 * * * /usr/bin/cminfo_updater
    0 */6 * * * /root/tools/updatecm.sh >/dev/null 2>&1

    Also some kind of update happens when I run centmin.sh
    "update wget to version... one time task" <-- happens every time though

    This was the first thing I tried.

    re. memcached:
    I haven't tried your most recent suggestion, but I couldn't help but notice the version you put up there was quite different from the one in my versions.txt :
    MEMCACHED_VERSION='1.4.24'
     
  7. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    might need to start with fresh 123.08stable code via below instructions

    Just do a fresh Centmin Mod code replacement by wiping /usr/local/src/centminmod as outlined similar to update guide here for older than .07 releases.

    replace branchname with branch you want either 123.08stable or 123.09beta01
    Code (Text):
    branchname=123.08stable
    cd /usr/local/src
    rm -rf centminmod*
    git clone https://github.com/centminmod/centminmod.git centminmod
    cd centminmod
    git checkout -f $branchname
     
  8. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    Memcached server version not same as memcache php extension version which is where memcache.php comes from
     
  9. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    ok -- I will try this! thanks!
     
  10. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    there's also log at /root/centminlogs/wget_source_install_${DT}.log for the wget routine so you can see what the problem is - can post contents to pastebin.com or gist.github.com to share
     
  11. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    wget logs are mostly empty:
    Code:
    cat /root/centminlogs/wget_source_install_190716-140642.log
    
    Total wget Install Time: .005801088 seconds
    After the fresh centmin install things look pretty similar. I still get "update wget to version... one time task" but I guess it's not doing anything.

    Both the admin stats files hang when loaded. I see no errors.

    I am going to reinstall memcached with the clean centminmod.

    I was going to start with Zend, but saw this:
    Reinstall Zend OpCache for PHP <5.5 or <5.6

    Did you mean =5.5 or =5.6?
     
  12. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    yeah <= should be that's fine

    centos 6 or 7 ?
     
  13. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    lsb_release -d

    Description: CentOS release 6.8 (Final)
     
  14. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    Also relevant: other php-based pages are running fine (thank goodness!)

    Do those admin stats pages depend on something in particular from the nginx conf file?
     
  15. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    the admin pages rely on working main hostname as outlined at step 1 of Getting Started guide so valid working dns for main hostname server_name defined in /usr/local/nginx/conf/conf.d/virtual.conf

    upload_2016-7-20_4-51-6.png
     
  16. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
  17. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    Thanks for all your help with this.

    Both admin stats pages are now up and running. I localized some custom nginx configuration and added the most recent virtual.conf file from centminmod, and that fixed things up. (My hostname configuration was already ok.)
     
    • Like Like x 1
  18. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    Great to hear :D
     
  19. RPGX

    RPGX New Member

    26
    4
    3
    Aug 14, 2014
    Ratings:
    +4
    Local Time:
    9:31 AM
    Nginx 1.9.15
    MariaDB 5.5.50
    Seems all set. The memcached install still doesn't dump an admin stats file (I tried running through it again) but your code worked well to create one.

    I tried clearing both caches from the command line using:
    # Zend, calls file with <?php opcache_reset(); ?>
    wget --spider http://127.0.0.1/opcache_reset.php
    #memcached
    echo 'flush_all' | nc -w 2 localhost 11211

    Zend clears about half way, and only one 'slab' of memcached clears using this method. I'm not sure what that's all about, but doing a service restart will do for now if I need to really empty it out.

    You need to add a comments box to your paypal donations so people can write a thank you note! Thanks!
     
    • Like Like x 1
  20. eva2000

    eva2000 Administrator Staff Member

    30,182
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    11:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    ah will look into that.. thanks :)

    to clear zend opcache just restart php-fpm :)