Deploy on AWS EC2 Ubuntu 23 error - ext-redis is missing

I’m deploying my web project (Laminas Framework with Composer) on Amazon AWS on EC2 instance running Ubuntu 23 with PHP8.1. Everything works fine before using Redis server for caching datas (sessions, translations files, etc.). On my local machine, everything works but when I deploy it on the EC2 instance, I get this error :

Is there any person who encoutered this type of problem ? Any suggestion to solve it please ?

When it says locked, delete composer.lock file and install again.

I tried but it does not work. I get the same error message

Package laminas/laminas-cache-storage-adapter-redis has requirements incompatible with your PHP version, PHP extensions and Composer version:
- laminas/laminas-cache-storage-adapter-redis 2.5.0 requires ext-redis ^4.3 || ^5.0.2 which does not match your installed version 6.0.0-dev.

Did you require or require --dev that package?

@Tyrsson , how can I require --dev that package ? When installing on local machine, I did not set this specification.

It is caused by this:
https://github.com/laminas/laminas-cache-storage-adapter-redis/blob/2.6.x/composer.json#L11

Its not per-say the package versions that is causing the composer issue from what it looks like its the ext-redis version itself that is causing your issue.

Since there is an entry for the ext-redis version composer is going to verify that its correct. Just like it will for your php version. As I understand it.

Might want to take a look at:
https://getcomposer.org/doc/articles/versions.md

Since it uses ^5.0.2 but its finding 6.0.0-dev it will not accept it because its a major version change. ^ will allow a bump in minor, but not in major. If I understand it correctly.

So, the question becomes where and how is the ext-redis 6.0.0-dev version being used instead of a stable 5.* version since the package can use that.

The last sentence says all. I’m looking for a solution since two weeks

Can you share your composer.json file content? I hope it doesn’t have any FBI secrets in it or any stock trade confidential information. If not please share it.

Is there a way in the EC2 configuration to specify which version of ext-redis is used? I’m not sure why a -dev version would be used there. Seems real bleeding edge to me for a production environment…

@ALTAMASH80 The composer.json that is causing the issue is the one from the storage adapter I linked to in my previous post. His issue (I think) is because for whatever reason his EC2 instance is using a ext-redis v6.0.0-dev (which I have not figured out how is possible, unless its a custom thing for AWS, which they do from time to time). – Edit – Might have found it. See below for the AWS link.

@ebuddy
I think your core issue is going to be because of this:

Maybe. But there is most likely what is supplying your 6.0.0 version.

Also, its not that ext-redis is missing. The issue is that composer is finding the wrong version.

You might want to try deploying it with this version specified:

SInce your composer constraint will allow patches and minor bumps. That “should” work. Then the next question is if the laminas adapter will play nice. Honestly, I do not know enough about it to even guess if it will work even if the install proceeds. But it might very well fix your composer issue. Which is the only thing I am addressing.

If that is not possible. You could also see this link and it explains how to ignore that constraint

Here is my composer.json file content

{
    "name": "laminas/laminas-mvc-skeleton",
    "description": "Laminas MVC Skeleton Application",
    "type": "project",
    "license": "BSD-3-Clause",
    "keywords": [
        "laminas",
        "mvc",
        "skeleton",
        "framework"
    ],
    "require": {
        "laminas/laminas-component-installer": "^3.2",
        "laminas/laminas-skeleton-installer": "^1.2",
        "laminas/laminas-mvc": "^3.6",
        "laminas/laminas-db": "^2.18",
        "laminas/laminas-mvc-form": "^2.1",
        "laminas/laminas-mvc-i18n": "^1.7",
        "laminas/laminas-mvc-plugins": "^1.2",
        "laminas/laminas-session": "^2.16",
        "laminas/laminas-crypt": "^3.10",
        "phpmailer/phpmailer": "^6.8",
        "aws/aws-sdk-php": "^3.269",
        "laminas/laminas-cli": "^1.8",
        "setasign/fpdf": "^1.8",
        "laminas/laminas-serializer": "^2.14",
        "laminas/laminas-navigation": "^2.18",
        "laminas/laminas-permissions-acl": "^2.14",
        "ifsnop/mysqldump-php": "^2.12",
        "laminas/laminas-recaptcha": "^3.6",
        "laminas/laminas-captcha": "^2.16",
        "phpseclib/phpseclib": "^3.0",
        "jbroadway/urlify": "^1.2",
        "laminas/laminas-log": "^2.16",
        "laminas/laminas-cache-storage-adapter-filesystem": "^2.0",
        "laminas/laminas-cache": "3.10",
        "laminas/laminas-cache-storage-deprecated-factory": "^1.1",
        "laminas/laminas-cache-storage-adapter-redis": "^2.5"
    },
    "autoload": {
        "psr-4": {
            "Application\\": "module/Application/src/",
            "Commun\\": "module/Commun/src/",
            "Admin\\": "module/Admin/src/",
            "Services\\": "module/Services/src/"
        }
    },
    "config": {
        "allow-plugins": {
            "laminas/laminas-component-installer": true,
            "laminas/laminas-skeleton-installer": true
        }
    },
    "require-dev": {
        "laminas/laminas-developer-tools": "^2.8"
    }
}

Hi @ebuddy,

Check your Redis version. If it outputs v6.0.0-dev. It means you need to downgrade your Redis version. To check the Redis version you can see this link.

Here is my redis version

@ebuddy ,
Damn! You’re using the windows cancer operating system for PHP development. I don’t know why I assumed you’re using some Linux version. For Windows, I’ve no clue how to resolve your issue. But what I can say is that you may need to downgrade your Redis cache version or install version 5 of Redis on your system. For that, you may need to uninstall the current Redis version 3.

@ALTAMASH80
Keep in mind, that the issue referenced is only happening when he deploys to AWS. That was the issue. Not what is installed on his local. It works there as he previously stated.

Thanks for the information that the EC2 instance can be deployed on a local machine. When I’ll use it I’ll keep this thread in mind.

@ALTAMASH80

In his first post. The screenshot is from where he is connected to that instance. The composer errors are being reported from the remote AWS instance.

Thank you bro. You clearly understood my problem.