Skip to content

Instantly share code, notes, and snippets.

@kovagoz
Created September 2, 2016 05:03
Show Gist options
  • Save kovagoz/0d6a24405d974c06f77cd2533b63b3f8 to your computer and use it in GitHub Desktop.
Save kovagoz/0d6a24405d974c06f77cd2533b63b3f8 to your computer and use it in GitHub Desktop.
Alpine Linux with PHP 5.6 FPM and Mongo module
FROM php:5.6-fpm-alpine
RUN apk update && apk add autoconf openssl-dev g++ make && \
pecl install mongo && \
docker-php-ext-enable mongo && \
apk del --purge autoconf openssl-dev g++ make
@babininja
Copy link

babininja commented Nov 13, 2022

I run the same code but got this error.

pecl/mongodb requires PHP (version >= 7.2.0, version <= 8.99.99), installed version is 5.6.40

can you help me solve this?

@mtrojanowski
Copy link

mtrojanowski commented Nov 14, 2022

@babininja If you use php 5.6. you should install the mongo extension. Exactly as in this example. The mongodb extension should be used only if you're on PHP >= 7.2. To switch to higher version of PHP change the first line of this Dockerfile to something like FROM php:8.1-fpm-alpine (use your desired version of PHP)

@babininja
Copy link

@mtrojanowski I am using php5.6-mongodb without docker and it works. but when i try to add it to docker file i can't. if i use php-mongo it gives me this error 'Class 'MongoDB\Driver\Manager' not found'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment