• Resolved fernandobrenes

    (@fernandobrenes)


    Hi,

    I have tried to configure the plugin to use Redis with unixsocket

    I have specified as HOST: /var/run/redis/redis.sock
    Port 0

    Also, I have tried to leave Port empty.

    When I click save I get in the debugs:

    04/22/20 17:27:57.705 [186.4.14.16:50073 1 4Md] ?? ——GET HTTP/1.1 (HTTPS) /wp-admin/admin.php
    04/22/20 17:27:57.705 [186.4.14.16:50073 1 4Md] Query String: page=lscache-settings&type=purge_all_lscache&settings-updated=true
    04/22/20 17:27:57.705 [186.4.14.16:50073 1 4Md] HTTP_REFERER: https://www.zonamotriz.com/wp-admin/admin.php?page=lscache-settings&type=purge_all_lscache
    04/22/20 17:27:57.705 [186.4.14.16:50073 1 4Md] Cookie _lscache_vary: admin_bar:1;logged-in:1;role:99
    04/22/20 17:27:57.937 [186.4.14.16:50073 1 4Md] [Ctrl] X Cache_control -> private ( logged in user )
    04/22/20 17:27:58.076 [186.4.14.16:50073 1 4Md] [Ctrl] X Cache_control -> no Cache ( Admin page )
    04/22/20 17:27:58.145 [186.4.14.16:50073 1 4Md] [Object] connecting to /var/run/redis/redis.sock:0
    04/22/20 17:27:58.146 [186.4.14.16:50073 1 4Md] [Object] Init Redis connection
    04/22/20 17:27:58.146 [186.4.14.16:50073 1 4Md] [Object] Failed to connect Redis server!
    04/22/20 17:27:58.149 [186.4.14.16:50073 1 4Md] [Ctrl] not cacheable before ctrl finalize
    04/22/20 17:27:58.149 [186.4.14.16:50073 1 4Md] [Router] get_uid: 112474
    04/22/20 17:27:58.149 [186.4.14.16:50073 1 4Md] [Router] get_role: administrator
    04/22/20 17:27:58.149 [186.4.14.16:50073 1 4Md] X-LiteSpeed-Cache-Control: no-cache
    04/22/20 17:27:58.149 [186.4.14.16:50073 1 4Md] [Optm] bypass: Not frontend HTML type
    04/22/20 17:27:58.149 [186.4.14.16:50073 1 4Md] End response

    I’m able to connect in the server without a problem:

    [root@himaxweb wp-content]# redis-cli -s /var/run/redis/redis.sock
    redis /var/run/redis/redis.sock> monitor
    OK

    I can only use Redis TCP as seen below.

    04/22/20 17:32:11.619 [186.4.14.16:63188 1 uWv] [Settings] validate_plugin_settings called
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Settings] Update .object_cache.ini and flush object cache
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] Reconnecting
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] init
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] init with cfg result : — true
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] connecting to 127.0.0.1:6379
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] Init Redis connection
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] Connected
    04/22/20 17:32:11.620 [186.4.14.16:63188 1 uWv] [Object] flush!

    Is it supported to use Redis unixsocket? If yes, could you please let me know what I’m missing or how can be debugged?

    Thank you,
    Best Regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Please make sure that you have set port to 0 when you use socket

    Best regards,

    Thread Starter fernandobrenes

    (@fernandobrenes)

    Hi @qtwrk ,

    Thank you for your time. I did, please check the debug.log above.

    04/22/20 17:27:58.145 [186.4.14.16:50073 1 4Md] [Object] connecting to /var/run/redis/redis.sock:0 <========

    Thank you,
    Best Regards

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Could you please create a php file , with code

    <?php
    $r = new Redis();
    $result = $r->connect('/var/run/redis/redis.sock');
    var_dump($result);
    ?>

    access it , then post the result ?

    Best regards,

    • This reply was modified 4 years, 7 months ago by qtwrk.
    • This reply was modified 4 years, 7 months ago by qtwrk.
    Thread Starter fernandobrenes

    (@fernandobrenes)

    Hi @qtwrk ,

    Sure, please see below:

    [root@himaxweb bin]# cat /root/tools/scripts/script1.php
    <?php
    $r = new Redis();
    $result = $r->connect(‘/var/run/redis/redis.sock’);
    var_dump($result);
    ?>

    [root@himaxweb bin]# ./php /root/tools/scripts/script1.php
    bool(true)

    Litespeed Logs:
    04/22/20 20:36:28.491 [186.4.14.16:49642 1 64t] [Ctrl] X Cache_control -> no Cache ( Admin page )
    04/22/20 20:36:28.559 [186.4.14.16:49642 1 64t] [Object] connecting to /var/run/redis/redis.sock:0
    04/22/20 20:36:28.559 [186.4.14.16:49642 1 64t] [Object] Init Redis connection
    04/22/20 20:36:28.559 [186.4.14.16:49642 1 64t] [Object] Failed to connect Redis server!

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Please run it by URL ,like https://domain.com/script1.php

    when you run it by root , the PHP runs as root , while being root , it has access to everything.

    You need to run it as your site’s PHP user does.

    Best regards,

    Thread Starter fernandobrenes

    (@fernandobrenes)

    Hi @qtwrk,

    Thank you for pointing me to the right direction ??

    I created a templated using the script and I got a permission denied so you are right, access to /var/run/redis/redis.sock was own by redis:redis so I change it to redis:nobody Now it works perfectly.

    Thank you!
    Best Regards

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    A better approach is to set Redis run as same user as PHP user ,

    I think make sock by nobody group might not be good idea for security as nobody user can read it which could be a security vulnerability

    Best regards,

    Thread Starter fernandobrenes

    (@fernandobrenes)

    Hi @qtwrk

    I agree with you ??

    I will configure now PHP SuEXEC.

    Thank you once again.
    Best regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Redis not working using unixsocket’ is closed to new replies.