{"id":3696,"date":"2018-04-20T18:16:03","date_gmt":"2018-04-20T15:16:03","guid":{"rendered":"http:\/\/mummila.net\/nuudelisoppa\/?p=3696"},"modified":"2018-04-20T18:16:03","modified_gmt":"2018-04-20T15:16:03","slug":"switching-redis-from-tcp-port-to-unix-socket-in-ubuntu-16-04-with-nextcloud-running-under-apache","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2018\/04\/20\/switching-redis-from-tcp-port-to-unix-socket-in-ubuntu-16-04-with-nextcloud-running-under-apache\/","title":{"rendered":"Switching Redis from TCP port to UNIX socket in Ubuntu 16.04, with Nextcloud running under Apache"},"content":{"rendered":"<p>This presumes that Apache, Nextcloud and Redis have already been installed, with Redis running on the default TCP port 6379 and Nextcloud is configured to use that port.<\/p>\n<p>When switching from using a port to using a socket, any &#8220;Redis Server Went Away&#8221; issues that crop up in Nextcloud are probably due to file permissions: Apache&#8217;s <code>www-data<\/code> user needs access to Redis&#8217; socket file inside <code>\/var\/run\/redis<\/code>. Here&#8217;s the full list of steps I took to make it work:<\/p>\n<ol>\n<li>open <code>${NEXTCLOUD_WWW_ROOT}\/config\/config.php<\/code> in a text editor<\/li>\n<li>turn on maintenance mode by setting <code>'maintenance' =&gt; true<\/code> and saving the file<\/li>\n<li>in the <code>'redis'<\/code> array,\n<ol>\n<li>set <code>'host' =&gt; '\/var\/run\/redis\/redis.sock'<\/code><\/li>\n<li>set <code>'port' =&gt; 0<\/code>\n<\/ol>\n<\/li>\n<li>save changes<\/li>\n<li>open <code>\/etc\/redis\/redis.conf<\/code> in a text editor<\/li>\n<li>change <code>port 6379<\/code> to <code>port 0<\/code>\n<li>uncomment <code>unixsocket \/var\/run\/redis\/redis.sock<\/code><\/li>\n<li>uncomment <code>unixsocketperm 700<\/code>\n<li>change <code>unixsocketperm 700<\/code> to <code>unixsocketperm 770<\/code><\/li>\n<li>save changes<\/li>\n<li><code>sudo adduser www-data redis<\/code><\/li>\n<li><code>sudo systemctl restart apache2<\/code> (for the added group to take effect)<\/li>\n<li><code>sudo systemctl restart redis-server<\/code><\/li>\n<li>open <code>${NEXTCLOUD_WWW_ROOT}\/config\/config.php<\/code> in a text editor<\/li>\n<li>turn off maintenance mode by setting <code>'maintenance' =&gt; false<\/code> and saving the file<\/li>\n<\/ol>\n<p>There&#8217;s no need to change the value of <a href=\"https:\/\/secure.php.net\/manual\/en\/ini.core.php#ini.open-basedir\"><code>open_basedir<\/code><\/a>, or to tweak Apache&#8217;s site configuration (but do remember step #12 above: restart Apache after adding <code>www-data<\/code> to the <code>redis<\/code> group).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This presumes that Apache, Nextcloud and Redis have already been installed, with Redis running on the default TCP port 6379 and Nextcloud is configured to use that port. When switching from using a port to using a socket, any &#8220;Redis Server Went Away&#8221; issues that crop up in Nextcloud are probably due to file permissions: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3696","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/3696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=3696"}],"version-history":[{"count":10,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/3696\/revisions"}],"predecessor-version":[{"id":3706,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/3696\/revisions\/3706"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=3696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=3696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=3696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}