1

The install instructions for memcache are not really up-to date. How do I install on Debian using php-fpm and nginx?

I tried this:

apt install memcache zlib1g-dev php-dev
pecl install memcache

This will install the extension into

/usr/lib/php/20220829/memcache.so

So I added

 echo extension = memcache.so>>/etc/php/8.1/fpm/php.ini

Then restarted

 service php8.1-fpm restart

Now I want to install the "Memcached Object Cache" Wordpress Plugin, but the plugin-website just sais:

  1. Install memcached on at least one server. Note the connection info. The default is 127.0.0.1:11211.

  2. Install the PECL memcache extension

  3. Copy object-cache.php to wp-content

  4. Add the WP_CACHE_KEY_SALT constant to the wp-config.php:

    define( 'WP_CACHE_KEY_SALT', '...long random string...' );
    

I cannot find object-cache.php anywhere.


The problem is, that phpize will use php8.2 to compile the extension. but if I uninstall php8.2, I also uninstall php-dev. If I reinstall it, it will try to install php8.2 again ;(

How do I solve this?

rubo77
  • 27,777
  • 43
  • 130
  • 199

4 Answers4

0

You have to install the plugin from within your wordpress-admin:

  1. go to plugins -> install
  2. search for "Memcached Object Cache"
  3. cp wp-content/plugins/memcached/object-cache.php wp-content/

note: this plug-in does not work with PHP 8.1. is this instead: https://github.com/php-memcached-dev/php-memcached/issues/536#issuecomment-1513459258

(With a final "d")

rubo77
  • 27,777
  • 43
  • 130
  • 199
0

You also have to install

apt install php-memcached

or more specific:

apt install php8.1-memcached

also add extension=memcached.so in your php.ini

(note the final "d" at "mamcached")

rubo77
  • 27,777
  • 43
  • 130
  • 199
0

Install Redis instead

I failed to get memcached running, so I installed redis with the "Redis Object Cache" – WordPress-Plugin:

apt purge php8.1-memcached php8.2-memcached libmemcached-dev memcached libmemcached-tools libmemcached11 libmemcachedutil2
service php8.2-fpm restart; service php8.1-fpm restart; service nginx restart
apt clean

curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

sudo apt update
sudo apt install redis php-redis php8.1-redis

Then I installed and activated the plugin in the Wordpress backend

rubo77
  • 27,777
  • 43
  • 130
  • 199
0

memcache and memcached are two different things. memchached is a networked cache-server, install using

apt install memcached and apt install php8.1-memcached

php-memcached can be configured to point to another memcached-server, the 127.0.0.1:11211 is memcached running on the local machine.

stoney
  • 1,046
  • 7
  • 9