Learn about Centmin Mod LEMP Stack today
Become a Member

Install Using Redis Unix sockets

Discussion in 'Add Ons' started by Mr. Jinx, Aug 8, 2021.

  1. Mr. Jinx

    Mr. Jinx New Member

    29
    8
    3
    Apr 18, 2021
    Ratings:
    +15
    Local Time:
    5:40 AM
    Did anyone every succeed in using Redis with sockets instead of TCP?

    I modified this in /etc/redis.conf:
    Code:
    port 0
    unixsocket /tmp/redis.sock
    unixsocketperm 777
    
    After a restart of Redis, the socket is created and I can do a ping:
    Code:
    redis-cli -s /tmp/redis.sock
    redis /tmp/redis.sock> ping
    PONG
    Seems to be working, but when I configure Xenforo to use the socket, it fails with an error:
    Code:
    Fatal error: Uncaught RedisException: No such file or directory in /home/nginx/domains/website/public/src/XF/CacheFactory.php:225 Stack trace: #0 /home/nginx/domains/website/public/src/XF/CacheFactory.php(225): Redis->pconnect('...', 0, 0) #1 /home/nginx/domains/website/public/src/XF/CacheFactory.php(79): XF\CacheFactory->createRedisCache(Array) #2 /home/nginx/domains/website/public/src/XF/CacheFactory.php(34): XF\CacheFactory->instantiate('...', Array) #3 /home/nginx/domains/website/public/src/XF/App.php(689): XF\CacheFactory->create('...', Array) #4 /home/nginx/domains/website/public/src/XF/Container.php(228): XF\App->XF\{closure}('', Array, Object(XF\Container)) #5 /home/nginx/domains/website/public/src/XF/App.php(2509): XF\Container->create('...', '') #6 /home/nginx/domains/website/public/src/XF/App.php(716): XF\App->cache('...') #7 /home/nginx/domains/website/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container)) #8 /home/nginx/domains/website/public/src/XF/App.php(1789): XF\Container->offsetGet('...') #9 /home/nginx/domains/website/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container)) #10 /home/nginx/domains/website/public/src/XF/App.php(1573): XF\Container->offsetGet('...') #11 /home/nginx/domains/website/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container)) #12 /home/nginx/domains/website/public/src/XF/App.php(2828): XF\Container->offsetGet('...') #13 /home/nginx/domains/website/public/src/XF/App.php(2856): XF\App->extension() #14 /home/nginx/domains/website/public/src/XF/App.php(361): XF\App->extendClass('...') #15 /home/nginx/domains/website/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container)) #16 /home/nginx/domains/website/public/src/XF/App.php(228): XF\Container->offsetGet('...') #17 /home/nginx/domains/website/public/src/XF/Container.php(28): XF\App->XF\{closure}(Object(XF\Container)) #18 /home/nginx/domains/website/public/src/XF/App.php(2453): XF\Container->offsetGet('...') #19 /home/nginx/domains/website/public/src/XF/Error.php(422): XF\App->request() #20 /home/nginx/domains/website/public/src/XF/Error.php(376): XF\Error->getExceptionTraceHtml(Object(RedisException)) #21 /home/nginx/domains/website/public/src/XF/App.php(2360): XF\Error->displayFatalExceptionMessage(Object(RedisException)) #22 /home/nginx/domains/website/public/src/XF.php(197): XF\App->displayFatalExceptionMessage(Object(RedisException)) #23 [internal function]: XF::handleException(Object(RedisException)) #24 {main} thrown in /home/nginx/domains/website/public/src/XF/CacheFactory.php on line 225
    I know the socket config should work, as I have used the same setup on another host which was shared hosting. But they also used Redis sockets.
    Just can't figure out why this wouldn't work.

     
  2. Pasta

    Pasta New Member

    14
    2
    3
    Aug 3, 2021
    Ratings:
    +6
    Local Time:
    11:40 AM
    Nginx 1.21.x
    MariaDB 10.4
    Might be openbase dir restriction.

    Try disabling it FAQ - CentminMod.com LEMP Nginx web stack for CentOS no 26.
     
  3. Mr. Jinx

    Mr. Jinx New Member

    29
    8
    3
    Apr 18, 2021
    Ratings:
    +15
    Local Time:
    5:40 AM
    Good one, I checked this but open_basedir was already commented out.
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,223
    12,116
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,654
    Local Time:
    1:40 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Just use TCP instead difference in performance for PHP Redis usage might not be that great given PHP overhead. The reason for the problem with Unix socket is they are by default owned by either root or redis user/group and PHP-FPM running with nginx user/group can't read them. Unless you know what you're doing to fix permissions for Redis unix socket usage, probably easier to just leave it as TCP.
     
  5. Mr. Jinx

    Mr. Jinx New Member

    29
    8
    3
    Apr 18, 2021
    Ratings:
    +15
    Local Time:
    5:40 AM
    Ok, yes performance was the reason for me to try this. I read some article about it.
    But if you say it is not worth it, I believe you :)