By whitgatewood
I’ve been using the memcached module with no problems on my site with PHP 5.5 and Ubuntu 14. I’m trying to update my site to PHP 5.6, but when I disable PHP 5.5 and enable PHP 5.6, the memcached module is no longer loaded when I restart Apache according to the phpinfo. How do I tell PHP 5.6 to load the memcached module?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
First you need to make sure that you have the php-memcache module installed for PHP 5.6, then you need to make sure that the memcache.so extension is specified in your PHP 5.6 php.ini file.
Hope that this helps.
Heya,
When upgrading PHP versions, it’s common to encounter issues with extensions that were working fine in older versions. This usually happens because the extension may not be compiled for the new version of PHP, or the configuration pointing to the extension is not set up for the new version. Here’s how you can ensure the memcached module is loaded for PHP 5.6, and I’ll also explain how to do it for PHP 8.1, as requested.
Step 1: Install the PHP 5.6 Memcached Module
First, ensure that the memcached module is installed for PHP 5.6. You might need to install it if it was only installed for PHP 5.5:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6-memcached
Step 2: Check if the Module is Enabled
You can check if the module is enabled by looking at the list of modules:
bashCopy code
php5.6 -m | grep memcached
Step 3: Ensure Configuration Files Are Correct
Ensure that the configuration for memcached is set up correctly in PHP 5.6’s mods-available directory:
memcached.ini or similar in /etc/php/5.6/mods-available/.extension=memcached.so.If the file exists and is configured correctly, make sure it’s symlinked in the conf.d directory for PHP 5.6:
sudo ln -s /etc/php/5.6/mods-available/memcached.ini /etc/php/5.6/apache2/conf.d/20-memcached.ini
sudo ln -s /etc/php/5.6/mods-available/memcached.ini /etc/php/5.6/cli/conf.d/20-memcached.ini
Step 4: Restart Apache
Restart Apache to apply the changes:
sudo service apache2 restart
Step 1: Install the PHP 8.1 Memcached Module
With PHP 8.1, the process is similar but tailored for the newer version:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php8.1-memcached
Step 2: Check if the Module is Enabled
Verify that the module is enabled for PHP 8.1:
php8.1 -m | grep memcached
Step 3: Ensure Configuration Files Are Correct
Check the mods-available directory for the memcached configuration:
memcached.ini in /etc/php/8.1/mods-available/.extension=memcached.so.Ensure the configuration file is linked to both the CLI and Apache2 configurations:
sudo ln -s /etc/php/8.1/mods-available/memcached.ini /etc/php/8.1/apache2/conf.d/20-memcached.ini
sudo ln -s /etc/php/8.1/mods-available/memcached.ini /etc/php/8.1/cli/conf.d/20-memcached.ini
Step 4: Restart Apache
Finally, restart Apache to make sure all settings take effect:
sudo service apache2 restart
/var/log/apache2/error.log) for any messages related to PHP or memcached.<?php phpinfo(); ?>
View this file in a browser to see if the memcached section appears, confirming the module is loaded correctly.
By following these steps, you should be able to get the memcached module working with both PHP 5.6 and PHP 8.1 on your Ubuntu system.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.