chialab/docker-php

Missing mcrypt to php7.2-fpm

Closed this issue ยท 4 comments

Hi man! Great project

How could I add mcrypt support in php7.2-fpm?

Hi @rafaelpatro , thanks for your interest.

According to PHP 7.2 upgrade instructions, mcrypt extension has now been moved to PECL due to some maintenance concerns. OpenSSL or Sodium extensions should be preferred instead.

We might install mcrypt to PHP 7.2 by running pecl install mcrypt and hopefully everything goes fine, but I'd rather install sodium instead. Is mcrypt in your application a non-refactorable requirement?

Yep! Mcrypt is required for Magento 1.
But I can use php7.1 for a while.

I'm trying to up 2 containers. Your php-fpm repo and a nginx-pagespeed.
Simple PHP files are running very well.

<?php phpinfo() ?>

The code above works great!
I don't know why but all Magento pages returns 404. I think it could be by different user:group permissions in php and nginx.

TY man! Nice work

Honestly I never used Magento, so I don't know much about it. You may refer to magento/magento2#12273 for a more in-depth discussion about Magento 1 and PHP 7.2's lack of mcrypt.

mcrypt has been removed from PHP 7.2 due to the fact that it hasn't received an update for ages, so there were security concerns around it. It is still available from PECL, but I value PHP's experts' opinion enough to think that it might not be a good idea to forcibly add something they removed due to serious concerns. ๐Ÿ™ƒ If you really know what you're doing, you may have your Dockerfile built this way:

FROM chialab/php:7.2-fpm

# Add this instruction BEFORE copying Magento files or running `composer install`, or whatever. :)
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libmcrypt-dev \
    && pecl install mcrypt-1.0.1 && docker-php-ext-enable mcrypt.so

# (your Dockerfile as usual)

About your 404 problem, it could be an Nginx configuration issue. My .conf files are more or less like this:

server {
    # ...

    location / {
        try_files $uri $uri/ /index.php?$args; # <-- This line is important! Try paths, or fallback on `index.php`.
    }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass php-container-alias:9000; # <-- Replace `php-container-alias` with actual value.
        fastcgi_index index.php;
        fastcgi_intercept_errors on;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # ...
}

Thanks @fquffio, docker instruction works like a charm.
Magento keeps 404 but this is another approach.
TY