No it isn't as easy as it looks! The default php version running on this Ubuntu 22.04 server is php7.4 and most of our applications run with it. Now we want to lift some applications, which run under the same domain on the same server (!) to php 8.2. We do that by adding a .htaccess file in the root folder of the application which looks like this:
<FilesMatch \.php>
SetHandler "proxy:unix:/var/run/php/php8.2-fpm.sock|fcgi://localhost/"
</FilesMatch>
This works fine.
But now I have an error and I suspect the cause is that for the php 8.2 version no memcached module is installed.
If I list under ll /etc/php/7.4/mods-available/
I get memcache.ini
listed.
If I do the same for ll /etc/php/8.2/mods-available/
nothing memcachelike is listed.
phpinfo()
for both environments confirms this.
Now my question: How can I install the module for php 8.2 without messing up the php7.4 configuration? All I found online was only about installing one version or installing a whole memcached server. I guess if I have the module present, I can enable it for the php version. I just have to get it there without doing any general upgrades.
If I search lauchpad for the exact package name https://launchpad.net/ubuntu/+search?text=memcache I only get as reasonable results "php-memcache" and "php-memcached" which both seem to be just the default package and not the one for a specific php version.
$ ll /etc/php
total 28
drwxr-xr-x 5 root root 4096 Apr 23 2024 ./
drwxr-xr-x 119 root root 12288 May 15 17:48 ../
drwxr-xr-x 6 root root 4096 Mar 2 2023 7.4/
drwxr-xr-x 6 root root 4096 Apr 23 2024 8.1/
drwxr-xr-x 6 root root 4096 Jan 18 2024 8.2/
$ ll /etc/php/8.2/
total 24
drwxr-xr-x 6 root root 4096 Jan 18 2024 ./
drwxr-xr-x 5 root root 4096 Apr 23 2024 ../
drwxr-xr-x 3 root root 4096 Jan 18 2024 apache2/
drwxr-xr-x 3 root root 4096 Mar 4 2024 cli/
drwxr-xr-x 4 root root 4096 Feb 3 13:30 fpm/
drwxr-xr-x 2 root root 4096 Feb 3 13:35 mods-available/
$ ll /etc/php/8.2/fpm/
total 176
drwxr-xr-x 4 root root 4096 Feb 3 13:30 ./
drwxr-xr-x 6 root root 4096 Jan 18 2024 ../
drwxr-xr-x 2 root root 4096 Feb 3 13:32 conf.d/
-rw-r--r-- 1 root root 5457 Dec 21 2023 php-fpm.conf
-rw-r--r-- 1 root root 74192 Apr 23 2024 php.ini
-rw-r--r-- 1 root root 74191 Jan 2 16:36 php.ini.ucf-dist
drwxr-xr-x 2 root root 4096 Feb 3 13:30 pool.d/
Given that Ubuntu 22.04 comes with PHP 8.1 by default, and that you have both 7.4 and 8.2 installed, it's likely that you've used the Ondrej PPA. You can determine if this PPA is present via either
sudo apt-cache policy | grep ondrej
Or:
sudo grep -r ondrej /etc/apt/
Given that, enabling a module for a specific version is a simple apt install
command:
apt install php<version>-<module>
Where <version>
is the PHP version in <major>.<minor>
format and <module>
is the name of the module. For example:
apt install php8.2-memcached
Note there are two different memcache modules for PHP -- one is called memcache
and one is called memcached
.