Bobcares

Memcache In Nextcloud | Setup Tutorial

With Memcache, we can greatly increase Nextcloud server performance. At Bobcares, with our Server Management Services, we can handle your server issues.

Memcache In Nextcloud

The memory caching of Nextcloud is the process of storing frequently-requested objects in memory for faster retrieval.

A PHP opcode cache, also known as opcache, and data caching for the Web server are the two types of caches to use. On the Nextcloud admin page, we will see a warning if we don’t install and enable a local memcache. We are not required to use a memcache, and we are safe to ignore the warning.

In order to avoid having to compile PHP scripts again each time they are called, they are stored in a PHP opcache. Since PHP version 5.5, the Zend OPcache is included in the core, eliminating the need for manual installation. Redis, Memcached, or the user (APCu) can provide data caching.

We can choose any of the below memcache backends in Nextcloud considering our needs:

  1. Memcached
  2. APCu
  3. Redis
memcache in nextcloud

By installing and enabling the desired cache, and then adding the necessary entry to config.php, Memcaches must be explicitly configured in Nextcloud. Then we should run the PHP version and information to make sure the chosen memcache is operational after installing and enabling it.

How To Set Up Memcache In Nextcloud?

We recommend using APCu and Redis. We have to run the below steps to configure memcache in Nextcloud:

1. Firstly, we have to do APCu and Redis installation.

$ sudo apt install php-apcu redis-server php-redis

$ sudo service apache2 restart

2. Now modify the config file.

$ sudo nano /etc/redis/redis.conf

Press Ctrl+w and enter “port” to search for port 6379 and change port 0. Then press Ctrl+w to search for and uncomment

unixsocket /var/run/redis/redis.sock
. Now uncomment the below code and change the permissions to 770:

unixsocketperm 700
to
unixsocketperm 770

Now press Ctrl+x, and the ‘Y’ to save and exit.

3. To the www-data group, add the Redis user redis:

$ sudo usermod -a -G redis www-data

4. We must restart Apache now:

$ sudo service apache2 restart

5. Also start the Redis server:

$ sudo service redis-server start

6. We must now include the caching configuration in the Nextcloud config file:

$ sudo nano /var/www/html/nextcloud/config/config.php

Add the below codes right after the last line and before the last parenthesis and semicolon.

'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.distributed' => '\\OC\\Memcache\\Memcached',
'redis' => 
array (
'host' => 'localhost',
'port' => 0,
'timeout' => 0.0,
),

7. Press Ctrl+x, then ‘Y’ to save and exit.

8. To make sure Redis is set to launch at boot, use the below code:

$ sudo systemctl enable redis-server

Now there will not be a “Security & Setup Warning” about memcache not being enabled when we visit Nextcloud’s admin page.

[Are you looking for a response to another query? Click here to contact us.]

Conclusion

The article briefly explains the steps from our Tech team to install and configure memory cache/memcache in the Nextcloud.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

5 Comments
  1. Hiba Razak

    Hi,
    Please contact our support team via live chat(click on the icon at right-bottom).

    Reply
  2. Farrukh Rehman

    Thanks, Work Perfectly with php8.0

    Reply
    • Hiba Razak

      Hi Farrukh,
      Thanks for the feedback.We are glad to know that our article helps you solves the issue ?

      Reply
  3. Lars K

    To my knowledge, it seems a ‘(‘ is missing somewhere? Im also getting Internal Server error after doing this.

    Add the below codes right after the last line and before the last parenthesis and semicolon.

    ‘memcache.local’ => ‘\\OC\\Memcache\\APCu’,
    ‘memcache.distributed’ => ‘\\OC\\Memcache\\Memcached’,
    ‘redis’ =>
    array (
    ‘host’ => ‘localhost’,
    ‘port’ => 0,
    ‘timeout’ => 0.0,
    ),

    —Where to put the missing “(“`?

    Reply
    • Lars K

      Sorry..I missread it and its working now..thank you.

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

server management

Spend time on your business, not on your servers.

TALK TO US

Or click here to learn more.

Speed issues driving customers away?
We’ve got your back!

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF