Your IP : 216.73.217.64
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Configuring Memory Caching — ownCloud 10.0.1 Server Administration Manual 10.0.1 documentation</title>
<link rel="stylesheet" href="../_static/" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/main.min.css" type="text/css" />
<link rel="stylesheet" href="../_static/styles.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '10.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="../_static/bootstrap-3.1.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../_static/bootstrap-sphinx.js"></script>
<link rel="top" title="ownCloud 10.0.1 Server Administration Manual 10.0.1 documentation" href="../contents.html" />
<link rel="up" title="Server Configuration" href="index.html" />
<link rel="next" title="Background Jobs" href="background_jobs_configuration.html" />
<link rel="prev" title="Virus Scanner Support" href="antivirus_configuration.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#1d2d44">
</head>
<body role="document">
<div class="wrap container not-front">
<div class="content row">
<main class="main">
<div class="row page-content-header">
<div class="col-md-5 col-md-offset-7">
<form class="headersearch" style="margin-bottom:-3px;" action="../search.html" method="get">
<input type="text" value="" name="q" id="q" class="form-control" />
<button class="btn btn-default" type="submit" id="searchsubmit">Search</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="sidebar">
<div class="menu-support-container">
<ul id="menu-support" class="menu">
<ul>
<li><a href="../contents.html">Table of Contents</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release_notes.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../whats_new_admin.html">What’s New in ownCloud 10.0.1</a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_database/index.html">Database Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_files/index.html">File Sharing and Management</a></li>
<li class="toctree-l1"><a class="reference internal" href="../maintenance/index.html">Maintenance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_mimetypes/index.html">Mimetypes Management</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Server Configuration</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="security_setup_warnings.html">Warnings on Admin Page</a></li>
<li class="toctree-l2"><a class="reference internal" href="import_ssl_cert.html">Importing System-wide and Personal SSL Certificates</a></li>
<li class="toctree-l2"><a class="reference internal" href="occ_command.html">Using the occ Command</a></li>
<li class="toctree-l2"><a class="reference internal" href="activity_configuration.html">Configuring the Activity App</a></li>
<li class="toctree-l2"><a class="reference internal" href="antivirus_configuration.html">Virus Scanner Support</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">Configuring Memory Caching</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#caching-exceptions">Caching Exceptions</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id1">APCu</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">Memcached</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">Redis</a></li>
<li class="toctree-l3"><a class="reference internal" href="#cache-directory-location">Cache Directory Location</a></li>
<li class="toctree-l3"><a class="reference internal" href="#recommendations-based-on-type-of-deployment">Recommendations Based on Type of Deployment</a></li>
<li class="toctree-l3"><a class="reference internal" href="#additional-redis-installation-help">Additional Redis Installation Help</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="background_jobs_configuration.html">Background Jobs</a></li>
<li class="toctree-l2"><a class="reference internal" href="config_sample_php_parameters.html">Config.php Parameters</a></li>
<li class="toctree-l2"><a class="reference internal" href="email_configuration.html">Email Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="excluded_blacklisted_files.html">Excluding Directories and Blacklisting Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="external_sites.html">Linking External Sites</a></li>
<li class="toctree-l2"><a class="reference internal" href="custom_client_repos.html">Custom Client Download Repositories</a></li>
<li class="toctree-l2"><a class="reference internal" href="knowledgebase_configuration.html">Knowledge Base Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="language_configuration.html">Language Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="logging_configuration.html">Logging Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="harden_server.html">Hardening and Security Guidance</a></li>
<li class="toctree-l2"><a class="reference internal" href="reverse_proxy_configuration.html">Reverse Proxy Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="thirdparty_php_configuration.html">Using Third Party PHP Components</a></li>
<li class="toctree-l2"><a class="reference internal" href="js_css_asset_management_configuration.html">JavaScript and CSS Asset Management</a></li>
<li class="toctree-l2"><a class="reference internal" href="automatic_configuration.html">Automatic Configuration Setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="oc_server_tuning.html">ownCloud Server Tuning</a></li>
<li class="toctree-l2"><a class="reference internal" href="index_php_less_urls.html">Enable index.php-less URLs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_user/index.html">User Management</a></li>
<li class="toctree-l1"><a class="reference internal" href="../issues/index.html">Issues and Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../enterprise/index.html">Enterprise Features</a></li>
</ul>
</ul>
</div>
</div>
</div>
<div class="col-md-9">
<div class="page-content">
<ul class="prevnext-title list-unstyled list-inline">
<li class="prev">
<a href="antivirus_configuration.html" title="Previous Chapter: Virus Scanner Support"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm">« Virus Scanner...</span>
</a>
</li>
<li class="next">
<a href="background_jobs_configuration.html" title="Next Chapter: Background Jobs"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm">Background Jobs »</span>
</a>
</li>
</ul>
<div class="section" id="configuring-memory-caching">
<h1>Configuring Memory Caching<a class="headerlink" href="#configuring-memory-caching" title="Permalink to this headline">¶</a></h1>
<p>You can significantly improve your ownCloud server performance with memory
caching, where frequently-requested objects are stored in memory for faster
retrieval. There are two types of caches to use: a PHP opcode cache, which is
commonly called <em>opcache</em>, and data caching for your Web server. If you do not
install and enable a local memory cache you will see a warning on your ownCloud
admin page. <strong>A memcache is not required and you may safely ignore the warning
if you prefer.</strong></p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you enable only a distributed cache in
your <code class="docutils literal"><span class="pre">config.php</span></code> (<code class="docutils literal"><span class="pre">memcache.distributed</span></code>) and not a
local cache (<code class="docutils literal"><span class="pre">memcache.local</span></code>) you will still see the cache warning.</p>
</div>
<p>A PHP opcache stores compiled PHP scripts so they don’t need to be re-compiled
every time they are called. PHP bundles the Zend OPcache in core since version
5.5, so you don’t need to install an opcache for PHP 5.6+.</p>
<p>Data caching is supplied by the Alternative PHP Cache, user (APCu) in PHP
5.6+, Memcached, or Redis.</p>
<p>ownCloud supports multiple memory caching backends, so you can choose the type
of memcache that best fits your needs. The supported caching backends are:</p>
<ul>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://pecl.php.net/package/APCu">APCu</a>, APCu 4.0.6 and up required.</dt>
<dd><p class="first last">A local cache for systems running PHP 5.6 and up.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="http://www.memcached.org/">Memcached</a></dt>
<dd><p class="first last">Distributed cache for multi-server ownCloud installations.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="http://redis.io/">Redis</a>, PHP module 2.2.6 and up required.</dt>
<dd><p class="first last">For distributed caching.</p>
</dd>
</dl>
</li>
</ul>
<p>Memory caches must be explicitly configured in ownCloud 8.1 and up by installing
and enabling your desired cache, and then adding the appropriate entry to
<code class="docutils literal"><span class="pre">config.php</span></code> (See <a class="reference internal" href="config_sample_php_parameters.html"><em>Config.php Parameters</em></a> for an overview of
all possible config parameters).</p>
<p>You may use both a local and a distributed cache. Recommended caches are APCu
and Redis. After installing and enabling your chosen memory cache, verify that it is
active by running <a class="reference internal" href="../issues/general_troubleshooting.html#label-phpinfo"><span>PHP Version and Information</span></a>.</p>
<div class="section" id="caching-exceptions">
<h2>Caching Exceptions<a class="headerlink" href="#caching-exceptions" title="Permalink to this headline">¶</a></h2>
<p>If ownCloud is configured to use either Memcached or Redis as a memory cache,
please be aware that you may encounter issues with functionality.
When these occur, it is usually a result of PHP being incorrectly configured, or
the relevant PHP extension not being available.</p>
<p>In the table below, you can see all of the known reasons for reduced or broken
functionality related to caching.</p>
<table border="1" class="docutils">
<colgroup>
<col width="41%" />
<col width="59%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Setup/Configuration</th>
<th class="head">Result</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>If file locking is enabled, but the locking
cache class is missing, then an exception
will appear in the web UI</td>
<td>The application will not be usable</td>
</tr>
<tr class="row-odd"><td>If file locking is enabled and the locking
cache is configured, but the PHP module
missing.</td>
<td>There will be a white page/exception in web UI. It
will be a full page issue, and the application will not be
usable</td>
</tr>
<tr class="row-even"><td>All enabled, but the Redis server is not
running</td>
<td>The application will be usable. But any file operation will
return a <strong>“500 Redis went away”</strong> exception</td>
</tr>
<tr class="row-odd"><td>If Memcache is configured for “local” and
“distributed”, but the class is missing</td>
<td>There will be a white page and an exception written to the logs,
This is because autoloading needs the missing class. So there is
no way to show a page</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id1">
<h2>APCu<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<p>PHP 5.6 and up include the Zend OPcache in core, and on most Linux
distributions it is enabled by default. However, it does
not bundle a data cache. APCu is a data cache, and it is available in most
Linux distributions. On Red Hat/CentOS/Fedora systems running PHP 5.6 and up
install <code class="docutils literal"><span class="pre">php-pecl-apcu</span></code>. On Debian/Ubuntu/Mint systems install <code class="docutils literal"><span class="pre">php5-apcu</span></code>.
On Ubuntu 14.04LTS, the APCu version is 4.0.2, which is too old to use with ownCloud.
ownCloud requires 4.0.6+. You may install 4.0.7 from Ubuntu backports with this command:</p>
<div class="highlight-python"><div class="highlight"><pre>apt-get install php5-apcu/trusty-backports
</pre></div>
</div>
<p>Then restart your Web server.</p>
<p>After restarting your Web server, add this line to your <code class="docutils literal"><span class="pre">config.php</span></code> file:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.local' => '\OC\Memcache\APCu',
</pre></div>
</div>
<p>Refresh your ownCloud admin page, and the cache warning should disappear.</p>
</div>
<div class="section" id="id2">
<h2>Memcached<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>Memcached is a reliable old-timer for shared caching on distributed servers.
It performs well with ownCloud with one exception: it is not suitable to use
with <a class="reference internal" href="../configuration_files/files_locking_transactional.html"><em>Transactional File Locking</em></a>.
This is because it does not store locks, and data can disappear from the cache
at any time.
Given that, Redis is the best memory cache to use.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Be sure to install the <strong>memcached</strong> PHP module, and not memcache, as
in the following examples. ownCloud supports only the <strong>memcached</strong> PHP
module.</p>
</div>
<div class="section" id="setting-up-memcached">
<h3>Setting Up Memcached<a class="headerlink" href="#setting-up-memcached" title="Permalink to this headline">¶</a></h3>
<p>On Debian/Ubuntu/Mint install <code class="docutils literal"><span class="pre">memcached</span></code> and <code class="docutils literal"><span class="pre">php5-memcached</span></code>.
The installer will automatically start <code class="docutils literal"><span class="pre">memcached</span></code> and configure it to launch
at startup.</p>
<p>On Red Hat/CentOS/Fedora install <code class="docutils literal"><span class="pre">memcached</span></code> and <code class="docutils literal"><span class="pre">php-pecl-memcached</span></code>.
It will not start automatically, so you must use your service manager to start
<code class="docutils literal"><span class="pre">memcached</span></code>, and to launch it at boot as a daemon.</p>
<p>You can verify that the Memcached daemon is running using the command: <code class="docutils literal"><span class="pre">ps</span>
<span class="pre">ax</span></code>, as follows:</p>
<div class="highlight-python"><div class="highlight"><pre>ps ax | grep memcached
19563 ? Sl 0:02 /usr/bin/memcached -m 64 -p 11211 -u memcache -l
127.0.0.1
</pre></div>
</div>
<p>Restart your Web server, add the appropriate entries to your
<code class="docutils literal"><span class="pre">config.php</span></code>, and refresh your ownCloud admin page. This example uses APCu
for the local cache, Memcached as the distributed memory cache, and lists all the
servers in the shared cache pool with their port numbers:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Memcached',
'memcached_servers' => array(
array('localhost', 11211),
array('server1.example.com', 11211),
array('server2.example.com', 11211),
),
</pre></div>
</div>
</div>
</div>
<div class="section" id="id3">
<h2>Redis<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>Redis is an excellent modern memcache to use for both distributed caching, and
as a local cache for <a class="reference internal" href="../configuration_files/files_locking_transactional.html"><em>Transactional File Locking</em></a> because it guarantees
that cached objects are available for as long as they are needed.</p>
<p>The Redis PHP module must be version 2.2.6+. If you are running a Linux
distribution that does not package the supported versions of this module, or
does not package Redis at all, see <a class="reference internal" href="#install-redis-label"><span>Additional Redis Installation Help</span></a>.</p>
<p>On Debian/Ubuntu/Mint install <code class="docutils literal"><span class="pre">redis-server</span></code> and <code class="docutils literal"><span class="pre">php5-redis</span></code>. The installer
will automatically launch <code class="docutils literal"><span class="pre">redis-server</span></code> and configure it to launch at
startup.</p>
<p>On CentOS and Fedora install <code class="docutils literal"><span class="pre">redis</span></code> and <code class="docutils literal"><span class="pre">php-pecl-redis</span></code>. It will not
start automatically, so you must use your service manager to start
<code class="docutils literal"><span class="pre">redis</span></code>, and to launch it at boot as a daemon.</p>
<p>You can verify that the Redis daemon is running with <code class="docutils literal"><span class="pre">ps</span> <span class="pre">ax</span></code>:</p>
<div class="highlight-python"><div class="highlight"><pre>ps ax | grep redis
22203 ? Ssl 0:00 /usr/bin/redis-server 127.0.0.1:6379
</pre></div>
</div>
<p>Restart your Web server, add the appropriate entries to your <code class="docutils literal"><span class="pre">config.php</span></code>, and
refresh your ownCloud admin page. This example <code class="docutils literal"><span class="pre">config.php</span></code> configuration uses
Redis for the local server cache:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.local' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),
</pre></div>
</div>
<p>For best performance, use Redis for file locking by adding this:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.locking' => '\OC\Memcache\Redis',
</pre></div>
</div>
<p>If you want to connect to Redis configured to listen on an Unix socket (which is
recommended if Redis is running on the same system as ownCloud) use this example
<code class="docutils literal"><span class="pre">config.php</span></code> configuration:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.local' => '\OC\Memcache\Redis',
'redis' => array(
'host' => '/var/run/redis/redis.sock',
'port' => 0,
),
</pre></div>
</div>
<p>Redis is very configurable; consult <a class="reference external" href="http://redis.io/documentation">the Redis documentation</a> to learn more.</p>
</div>
<div class="section" id="cache-directory-location">
<h2>Cache Directory Location<a class="headerlink" href="#cache-directory-location" title="Permalink to this headline">¶</a></h2>
<p>The cache directory defaults to <code class="docutils literal"><span class="pre">data/$user/cache</span></code> where <code class="docutils literal"><span class="pre">$user</span></code> is the
current user. You may use the <code class="docutils literal"><span class="pre">'cache_path'</span></code> directive in <code class="docutils literal"><span class="pre">config.php</span></code>
(See <a class="reference internal" href="config_sample_php_parameters.html"><em>Config.php Parameters</em></a>) to select a different location.</p>
</div>
<div class="section" id="recommendations-based-on-type-of-deployment">
<h2>Recommendations Based on Type of Deployment<a class="headerlink" href="#recommendations-based-on-type-of-deployment" title="Permalink to this headline">¶</a></h2>
<div class="section" id="small-private-home-server">
<h3>Small/Private Home Server<a class="headerlink" href="#small-private-home-server" title="Permalink to this headline">¶</a></h3>
<p>Only use APCu:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.local' => '\OC\Memcache\APCu',
</pre></div>
</div>
</div>
<div class="section" id="small-organization-single-server-setup">
<h3>Small Organization, Single-server Setup<a class="headerlink" href="#small-organization-single-server-setup" title="Permalink to this headline">¶</a></h3>
<p>Use APCu for local caching, Redis for file locking:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),
</pre></div>
</div>
</div>
<div class="section" id="large-organization-clustered-setup">
<h3>Large Organization, Clustered Setup<a class="headerlink" href="#large-organization-clustered-setup" title="Permalink to this headline">¶</a></h3>
<p>Use Redis for everything except a local memory cache.
Use the server’s IP address or hostname so that it is accessible to other hosts:</p>
<div class="highlight-python"><div class="highlight"><pre>'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\APCu',
'redis' => array(
'host' => 'server1', //hostname example
'host' => '12.34.56.78', //IP address example
'port' => 6379,
),
</pre></div>
</div>
</div>
<div class="section" id="additional-notes-for-redis-vs-apcu-on-memory-caching">
<h3>Additional notes for Redis vs. APCu on Memory Caching<a class="headerlink" href="#additional-notes-for-redis-vs-apcu-on-memory-caching" title="Permalink to this headline">¶</a></h3>
<p>APCu is faster at local caching than Redis. If you have enough memory, use APCu for Memory Caching
and Redis for File Locking. If you are low on memory, use Redis for both.</p>
</div>
</div>
<div class="section" id="additional-redis-installation-help">
<span id="install-redis-label"></span><h2>Additional Redis Installation Help<a class="headerlink" href="#additional-redis-installation-help" title="Permalink to this headline">¶</a></h2>
<p>If your version of Mint or Ubuntu does not package the required version of
<code class="docutils literal"><span class="pre">php5-redis</span></code>, then try <a class="reference external" href="https://www.techandme.se/how-to-configure-redis-cache-in-ubuntu-14-04-with-owncloud/">this Redis guide on Tech and Me</a> for a complete Redis installation on Ubuntu 14.04 using PECL.
These instructions are adaptable for any distro that does not package the
supported version, or that does not package Redis at all, such as SUSE Linux
Enterprise Server and Red Hat Enterprise Linux.</p>
<p>The Redis PHP module must be at least version 2.2.6.</p>
<p>See <a class="reference external" href="https://pecl.php.net/package/redis">https://pecl.php.net/package/redis</a></p>
<p>On Debian/Mint/Ubuntu, use <code class="docutils literal"><span class="pre">apt-cache</span></code> to see the available
<code class="docutils literal"><span class="pre">php5-redis</span></code> version, or the version of your installed package:</p>
<div class="highlight-python"><div class="highlight"><pre>apt-cache policy php5-redis
</pre></div>
</div>
<p>On CentOS and Fedora, the <code class="docutils literal"><span class="pre">yum</span></code> command shows available and installed version
information:</p>
<div class="highlight-python"><div class="highlight"><pre>yum search php-pecl-redis
</pre></div>
</div>
</div>
</div>
<ul class="prevnext-title list-unstyled list-inline">
<li class="prev">
<a href="antivirus_configuration.html" title="Previous Chapter: Virus Scanner Support"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm">« Virus Scanner...</span>
</a>
</li>
<li class="next">
<a href="background_jobs_configuration.html" title="Next Chapter: Background Jobs"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm">Background Jobs »</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</main>
</div>
</div>
</body>
</html>