Support » Plugin: WP Redis » WP_CACHE_KEY_SALT useless?

  • Resolved Luka

    (@darktwen)


    I’ve written a script to enable wp-redis for all my WP installations, on my cPanel server.

    for i in $(ls --hide='system' /var/cpanel/users/); do
      find /home/$i/public_html -name 'wp-admin' -print0 | while IFS= read -r -d $'\0' line; do
        cd $line/../;   
        randstring=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo;);
        echo "define ('WP_CACHE_KEY_SALT', '$randstring:');" >> wp-config.php;
    
        PHP_PATH="/opt/cpanel/ea-php56/root/usr/bin/php"
    
        sudo -H -u$i $PHP_PATH /home/wp core update-db;
    
        sudo -H -u$i $PHP_PATH -d "disable_functions=NULL" /home/wp plugin install wp-redis;
        sudo -H -u$i $PHP_PATH -d "disable_functions=NULL" /home/wp plugin activate wp-redis;
        rm -rfv wp-content/object-cache.php
        sudo -H -u$i $PHP_PATH -d "disable_functions=NULL" /home/wp redis enable;
        sudo -H -u$i $PHP_PATH -d "disable_functions=NULL" /home/wp redis info;
      done;  
    done
    

    And after all went well, I realized sites started randomly redirecting to each other.
    Even though this random string is being added to each wp-config.php

    define ('WP_CACHE_KEY_SALT', 'xxxxxxxxxxxxxxxxxxxxxx:');

    With another plugin, redis-cache, this works perfectly, but with that plugin, I have problem with “You’re not authorized to view this page” and with yours, I do not, but I can’t use WP_CACHE_KEY_SALT.

    Any guidance would be highly appreciated. Are there any specific requirements for this key value? Am I doing something wrong?

    • This topic was modified 5 months, 3 weeks ago by  Luka.
    • This topic was modified 5 months, 3 weeks ago by  Luka.
    • This topic was modified 5 months, 3 weeks ago by  Luka.
    • This topic was modified 5 months, 3 weeks ago by  Luka.
    • This topic was modified 5 months, 3 weeks ago by  Jan Dembowski.
    • This topic was modified 5 months, 3 weeks ago by  Jan Dembowski.
Viewing 4 replies - 1 through 4 (of 4 total)
  • @jdembowski you didn’t need to censor salt I generated it for this topic so that author can tell me if my syntax is wrong or something. It’s generated using this

    randstring=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo;);
    for each site individually.

    define ('WP_CACHE_KEY_SALT', 'r526JkOEUCM1vEZS1D0T9FJLlNON1xtH:');

    • This reply was modified 5 months, 3 weeks ago by  Luka.
    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Even though this random string is being added to each wp-config.php

    If you add the constant to the end of the wp-config.php file, it won’t be loaded until after the entire request has been processed. You need to put the constant at the top of wp-config.php.

    That should’ve been mentioned in documentation 😀

    Thanks, works amazing. I now activated your plugin for all my hosting customers 😉

    Here’s complete working bash script if anyone with cPanel server wants to do this for all sites too:

    https://github.com/lukapaunovic/wp-redis-enable-all-installs-cpanel

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.