Redis not working on centos 7: Exception:RedisException, Message: Permission denied, Code:0, RedisFactory.php(83)

redis
10

#1

Steps to reproduce

I am installing owncloud 10 on my CentOS 7 server, the very last task is to make redis work and I’m having the error mentioned in the title. Here are my tests:

scenario 1:

/etc/redis.conf default options
owncloud/config/config.php :

'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis': {
    'host' => 'localhost',
    'port' => 6379,
},
scenario 2:

/etc/redis.conf :

port 0
unixsocket /var/run/redis/redis.sock
unixsocketperm 775

owncloud/config/config.php :

'filelocking.enabled' => 'true',
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',

'redis' => array (
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'timeout' => 0,
),

Expected behaviour

owncloud should load normally but redis or one of its scripts doesnt seem to have proper permissions

Actual behaviour

Internal Server Error (log attached below), but also I would like to point that redis is working in both scenarios

scenario 1:
# redis-cli ping
PONG
scenario 2:
# redis-cli -s /var/run/redis/redis.sock ping
PONG

Here are the folder permitions for socket:

# ls -la /var/run/redis/
total 0
drwxr-xr-x.  2 redis redis  60 Jun  3 19:57 .
drwxr-xr-x. 27 root  root  780 Jun  3 19:57 ..
srwxrwxr-x.  1 redis redis   0 Jun  3 19:57 redis.sock

Also here is the redis log:

/var/log/redis/redis.log
27818:M 03 Jun 19:57:56.430 * DB loaded from disk: 0.000 seconds
27818:M 03 Jun 19:57:56.430 * The server is now ready to accept connections at /var/run/redis/redis.sock

Server configuration

Operating system: CentOS 7
Web server: Apache
Database: MySQL
PHP version: PHP 7.2.6
ownCloud version: 10
Updated from an older ownCloud or fresh install: Fresh
Where did you install ownCloud from:

The content of config/config.php:

{"reqId":"WxSI8i5q4bRIr74YbR6b2QAAAAE","level":3,"time":"2018-06-04T00:33:54+00:00","remoteAddr":"192.168.0.3","user":"whgandalf","app":"index","method":"GET","url":"\/index.php\/settings\/admin?sectionid=general","message":"Exception: {\"Exception\":\"RedisException\",\"Message\":\"Permission denied\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php(83): Redis->connect('\\\/var\\\/run\\\/redis\\\/...', 0, 0)\\n#1 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php(103): OC\\\\RedisFactory->create()\\n#2 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Memcache\\\/Redis.php(37): OC\\\\RedisFactory->getInstance()\\n#3 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Memcache\\\/Factory.php(132): OC\\\\Memcache\\\\Redis->__construct('75f87d2144af472...')\\n#4 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Server.php(712): OC\\\\Memcache\\\\Factory->createLocking('lock')\\n#5 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/composer\\\/pimple\\\/pimple\\\/src\\\/Pimple\\\/Container.php(113): OC\\\\Server->OC\\\\{closure}(Object(OC\\\\Server))\\n#6 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(111): Pimple\\\\Container->offsetGet('LockingProvider')\\n#7 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/ServerContainer.php(87): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query('LockingProvider')\\n#8 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Server.php(1465): OC\\\\ServerContainer->query('LockingProvider')\\n#9 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Files\\\/View.php(118): OC\\\\Server->getLockingProvider()\\n#10 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Server.php(168): OC\\\\Files\\\\View->__construct()\\n#11 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/composer\\\/pimple\\\/pimple\\\/src\\\/Pimple\\\/Container.php(113): OC\\\\Server->OC\\\\{closure}(Object(OC\\\\Server))\\n#12 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/AppFramework\\\/Utility\\\/SimpleContainer.php(111): Pimple\\\\Container->offsetGet('EncryptionManag...')\\n#13 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/ServerContainer.php(87): OC\\\\AppFramework\\\\Utility\\\\SimpleContainer->query('EncryptionManag...')\\n#14 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/Server.php(900): OC\\\\ServerContainer->query('EncryptionManag...')\\n#15 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/base.php(753): OC\\\\Server->getEncryptionManager()\\n#16 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/base.php(671): OC::registerEncryptionWrapper()\\n#17 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/base.php(997): OC::init()\\n#18 \\\/var\\\/www\\\/html\\\/owncloud\\\/index.php(54): require_once('\\\/var\\\/www\\\/html\\\/o...')\\n#19 {main}\",\"File\":\"\\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/RedisFactory.php\",\"Line\":83}"}

I have tried everything but I am afraid there is something beyond my sight.


#2

From my limited knowledge about CentOS such permission / connectivity issues where often / most times caused by SELinux.


#3

Part of my problem was SELinux and the rest was Redis, I found the solution though (posted bellow)


#4

I found there were two important things missing in my installation:

Setting up SELinux properly to Owncloud as mentioned here:

https://doc.owncloud.org/server/10.0/admin_manual/installation/selinux_configuration.html

and setting up redis to work properly with socket as mentioned here:

https://doc.owncloud.org/server/10.0/admin_manual/installation/selinux_configuration.html

I created users before, I had to re create them to apply the new rules.