Connecting to Memcached on Web Hosting

How to configure Memcached in popular CMS platforms on Web Hosting.

On Web Hosting, Memcached is accessed via a Unix socket. Both the memcache and memcached PHP extensions are supported. Each user gets 32 MB of memory by default — to increase the limit, submit a request via the ticket system.

The socket path format depends on which PHP extension you're using.

For the php-memcache extension:

Socket path: unix:///user_home_directory/.memcached/memcached.sock
Port: 0

For the php-memcached extension:

Socket path: user_home_directory/.memcached/memcached.sock
Port: 0

The home directory path is shown on the cPanel home page under General information.

General information in cPanel General information in cPanel

Joomla 5

Joomla has built-in Memcached support — no additional plugins required.

Log in to the admin panel and go to SystemGlobal configurationSystem. Under cache settings, configure the following:

  • Cache handlerMemcached
  • Memcache(d) server hostuser_home_directory/.memcached/memcached.sock
  • Memcache(d) server port11211

Cache settings in Joomla Cache settings in Joomla

Click Save.

WordPress

WordPress doesn't support Memcached natively, but it can be added via the W3 Total Cache plugin.

In the plugin settings, go to the General settings tab and set Page cache method to Memcached.

W3 Total Cache — General settings W3 Total Cache — General settings

Then go to Page cacheAdvanced and set Memcached hostname:port / IP:port to:

user_home_directory/.memcached/memcached.sock:0

W3 Total Cache — Page cache W3 Total Cache — Page cache

OpenCart

OpenCart has built-in Memcached support.

OpenCart 3.0 — add the following to the end of both config.php and admin/config.php:

define('CACHE_HOSTNAME', '/home/YOUR_ACCOUNT/.system/memcache/socket');
define('CACHE_PORT', '0');
define('CACHE_PREFIX', 'oc_');

OpenCart 2.2–2.3 — add the following to both config files:

define('CACHE_HOSTNAME', 'unix:///home/YOUR_ACCOUNT/.system/memcache/socket');
define('CACHE_PORT', '0');
define('CACHE_PREFIX', 'oc_');

In system/config/default.php, replace:

$_['cache_type'] = 'file';

with:

$_['cache_type'] = 'mem';

Our products and services

Web HostingReliable hosting services for websites of any scale.
Order
VPSFlexible cloud infrastructure with full root access.
Order
Dedicated ServersBare metal servers for maximum performance.
Order

Bitrix

Bitrix supports Memcached via the php-memcache extension, which is available for PHP 5.3–5.6 only.

Add the following to bitrix/php_interface/dbconn.php:

define("BX_CACHE_TYPE", "memcache");
define("BX_CACHE_SID", $_SERVER["DOCUMENT_ROOT"]."#01");
define("BX_MEMCACHE_HOST", "unix:///user_home_directory/.memcached/memcached.sock");
define("BX_MEMCACHE_PORT", "0");

Add the following to bitrix/.settings_extra.php:

<?php
return array(
  'cache' => array(
    'value' => array(
      'type' => 'memcache',
      'memcache' => array(
        'host' => 'unix:///user_home_directory/.memcached/memcached.sock',
        'port' => '0',
      ),
      'sid' => $_SERVER["DOCUMENT_ROOT"]."#01"
    ),
  ),
);

If bitrix/.settings_extra.php doesn't exist, create it manually.

DLE

DLE has built-in Memcached support.

In the admin panel, go to System settingsOptimization. Set Site cache type to Memcache and enter the following in Memcache server connection details:

user_home_directory/.memcached/memcached.sock

Drupal

Drupal doesn't support Memcached natively — first install the Memcache module and enable it under Extensions.

Drupal 7 — add the following to the end of /sites/default/settings.php (replace your_login with your account name):

$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';
$conf['memcache_stampede_protection'] = TRUE;
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;
$conf['memcache_servers'] = array('unix:///home/your_login/.memcached/memcached.sock' => 'default');

Drupal 8+ — add the following to settings.php:

$settings['memcache']['servers'] = ['unix:///home/your_login/.memcached/memcached.sock' => 'default'];
$settings['memcache']['bins'] = ['default' => 'default'];
$settings['memcache']['key_prefix'] = '';
$settings['cache']['default'] = 'cache.backend.memcache';

Help

If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!

Need help?Our engineers will help you free of charge with any question in minutesContact us