Fix "Memcache Extension is Not Loaded" in Bitrix
1. Check if Memcache is Installed
First, verify whether the Memcache extension is already present on your system.
For other Bitrix tuning topics, see mbstring.func_overload Bitrix Guide, max_input_vars in Bitrix, Bitrix MySQL Freezes — Causes and Solutions, and Bitrix Error Log — Locate, Enable, Analyze.
php -m | grep memcache
Expected Results:
- If you see
memcacheormemcachedin the output, the extension is installed but may not be enabled for your web server's PHP configuration. - If there's no output, the extension is not installed and needs to be installed.
Also check if the Memcached service is running:
systemctl status memcached
And verify your PHP version to install the correct package:
php -v
2. Install the Memcache Extension
Memcache requires two components: the Memcached service/daemon and the PHP extension.
Step 1: Install Memcached Service
For Ubuntu/Debian Systems
sudo apt update
sudo apt install memcached libmemcached-tools -y
For CentOS/RHEL/Fedora Systems
sudo yum install memcached -y
After installation, start and enable the service:
sudo systemctl start memcached
sudo systemctl enable memcached
Step 2: Install PHP Memcache Extension
For Ubuntu/Debian (PHP 7.4)
sudo apt install php7.4-memcache php7.4-memcached -y
For Ubuntu/Debian (PHP 8.0)
sudo apt install php8.0-memcache php8.0-memcached -y
For Ubuntu/Debian (PHP 8.1)
sudo apt install php8.1-memcache php8.1-memcached -y
For CentOS/RHEL (via Remi Repository)
# Enable Remi repository first if needed
sudo yum install php-pecl-memcache php-pecl-memcached -y
Verify Installation
# Check both extensions
php -m | grep -E "memcache|memcached"
# You should see both memcache and memcached listed
3. Enable Memcache in PHP Configuration
If the extension is installed but not being loaded by your web server's PHP, you need to enable it in the appropriate php.ini file.
Find the Correct php.ini File
# For command-line PHP (initial check)
php --ini | grep "Loaded Configuration File"
# For web server PHP (may be different)
sudo find /etc -name "php.ini" | grep -E "(apache2|fpm|httpd)"
Edit php.ini
# For Apache on Ubuntu/Debian
sudo nano /etc/php/7.4/apache2/php.ini
# For PHP-FPM (Nginx) on Ubuntu/Debian
sudo nano /etc/php/7.4/fpm/php.ini
# For CentOS/RHEL
sudo nano /etc/php.ini
Add or Uncomment Extensions
Search for or add these lines in the extensions section:
extension=memcache.so
extension=memcached.so
Save the file (Ctrl+O, Enter, Ctrl+X).
Restart Web Services
# For Apache
sudo systemctl restart apache2
# For Nginx with PHP-FPM
sudo systemctl restart php7.4-fpm
sudo systemctl restart nginx
# For CentOS Apache
sudo systemctl restart httpd
# Always restart Memcached service too
sudo systemctl restart memcached
Verify Extension is Loaded
php -m | grep -E "memcache|memcached"
4. Configure Memcache for Bitrix
After installing and enabling the extension, configure Bitrix to use Memcache for caching.
Edit Bitrix Configuration File
Modify dbconn.php
sudo nano /home/user/public_html/bitrix/php_interface/dbconn.php
Replace /home/user/public_html/ with your actual Bitrix installation path.
Add Memcache Configuration
Find the section where cache settings are defined (usually near the end) and add or modify:
// Memcache configuration for Bitrix
define("BX_CACHE_TYPE", "memcache");
define("BX_MEMCACHE_HOST", "127.0.0.1");
define("BX_MEMCACHE_PORT", "11211");
define("BX_CACHE_SID", $_SERVER["DOCUMENT_ROOT"]."|site");
// Optional: Use Memcached instead (recommended)
// define("BX_CACHE_TYPE", "memcached");
// For multiple Memcache servers (clustered setup)
// define("BX_MEMCACHE_HOST", "mem1.site.com;mem2.site.com");
BX_CACHE_TYPE: Use"memcache"for the older extension or"memcached"for the newer oneBX_MEMCACHE_HOST:127.0.0.1for local server, or external IP/hostname for remoteBX_MEMCACHE_PORT: Default is 11211
Alternative: Configure via Bitrix Admin Panel
- Log into your Bitrix Admin Panel
- Go to Settings > System Settings > Cache Settings
- Select Memcache or Memcached as cache type
- Enter server details:
127.0.0.1:11211 - Save and clear cache
5. Test Memcache Installation
Method 1: PHP Info Test
# Create a test file (in a secure location, not web root for production)
echo "<?php phpinfo(); ?>" | sudo tee /home/user/public_html/test_memcache.php
Visit http://yourdomain.com/test_memcache.php and search for "memcache" or "memcached". You should see configuration sections for both extensions.
sudo rm /home/user/public_html/test_memcache.php
Method 2: Command Line Test
# Test Memcached service connectivity
echo "stats" | nc 127.0.0.1 11211
# Test PHP Memcache functionality
php -r "\$mem = new Memcache; \$mem->connect('127.0.0.1', 11211); echo \$mem->getVersion();"
Method 3: Bitrix Cache Test
- In Bitrix Admin Panel, go to Settings > System Settings > Performance
- Check if Memcache is detected in the cache section
- Run the cache test tool if available
6. Summary of Fixes
| Issue | Solution |
|---|---|
| Memcache not installed | sudo apt install php7.4-memcache php7.4-memcached |
| Memcache extension not loaded | Add extension=memcache.so and extension=memcached.so in php.ini |
| Bitrix not using Memcache | Configure dbconn.php with BX_CACHE_TYPE, BX_MEMCACHE_HOST, BX_MEMCACHE_PORT |
| Memcache service not running | sudo systemctl restart memcached |
| PHP version mismatch | Install correct version package: php7.4-memcache for PHP 7.4, etc. |
| Web server not recognizing changes | Restart Apache/Nginx and PHP-FPM services |
| Connection refused errors | Check firewall: sudo ufw allow 11211/tcp or firewall-cmd --add-port=11211/tcp |
With Memcache properly installed and configured, Bitrix will use memory-based caching to significantly improve page load times and reduce database load!


