Failure to install pecl mcrypt-1.0.6 on php:8.1.18-apache using docker-compose - Resolved [closed] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, April 30, 2023

Failure to install pecl mcrypt-1.0.6 on php:8.1.18-apache using docker-compose - Resolved [closed]

I have the following docker file for building a web server which is failing to install the mcrypt extension for php.

FROM php:8.1.18-apache
#COPY config/php.ini /usr/local/etc/php/
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
#        libmcrypt-dev \
        libpng-dev \
        git \
    && docker-php-ext-configure sockets \
    && docker-php-ext-install sockets \
#    && docker-php-ext-install mcrypt-1.0.5 \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd\
    && docker-php-ext-install -j$(nproc) mysqli\
#    && pecl install xdebug-2.5.0 \
    && pecl install xdebug-3.2.0 \
    && docker-php-ext-enable xdebug \
    && pecl install mcrypt-1.0.6 
#    && docker-php-ext-enable mcrypt

# Installation of Composer
RUN cd /usr/src && curl -sS http://getcomposer.org/installer | php
RUN cd /usr/src && mv composer.phar /usr/bin/composer

# Installation of tools with composer
RUN composer global require --no-plugins --no-scripts phpdocumentor/phpdocumentor
RUN composer global require --no-plugins --no-scripts squizlabs/php_codesniffer
RUN composer global require --no-plugins --no-scripts phpunit/phpunit
RUN composer global require --no-plugins --no-scripts phpunit/dbunit
RUN composer global require --no-plugins --no-scripts phploc/phploc
RUN composer global require --no-plugins --no-scripts phpmd/phpmd
RUN composer global require --no-plugins --no-scripts simpletest/simpletest


# Fix for Let's Encrypt root certificate failure
RUN sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
RUN update-ca-certificates

ENV PATH /root/.composer/vendor/bin:$PATH

The pecl file is downloaded, but the mcrypt.h file is not found. I don't know why this is happening? The php code that will run on the server was migrated from php 7.0 and requires mcrypt.

downloading mcrypt-1.0.6.tgz ...
Starting to download mcrypt-1.0.6.tgz (27,062 bytes)
.........done: 27,062 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
libmcrypt prefix? [autodetect] : building in /tmp/pear/temp/pear-build-defaultuserOrqVme/mcrypt-1.0.6
running: /tmp/pear/temp/mcrypt/configure --with-php-config=/usr/local/bin/php-config --with-mcrypt
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20210902
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for mcrypt support... yes, shared
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
ERROR: `/tmp/pear/temp/mcrypt/configure --with-php-config=/usr/local/bin/php-config --with-mcrypt' failed

The docker file is corrected to load libmcrypt as shown below and remove extraneous lines that were previously commented out.

FROM php:8.1.18-apache
# No need to copy the ini file because the folder is mapped to the server
#COPY config/php.ini /usr/local/etc/php/
#
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        git \
    && pecl install mcrypt-1.0.6 \
    && docker-php-ext-configure sockets \
    && docker-php-ext-install sockets \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd\
    && docker-php-ext-install -j$(nproc) mysqli\
    && pecl install xdebug-3.2.0 \
    && docker-php-ext-enable xdebug 

# Installation of Composer
RUN cd /usr/src && curl -sS http://getcomposer.org/installer | php
RUN cd /usr/src && mv composer.phar /usr/bin/composer

# Installation of tools with composer
RUN composer global require --no-plugins --no-scripts phpdocumentor/phpdocumentor
RUN composer global require --no-plugins --no-scripts squizlabs/php_codesniffer
RUN composer global require --no-plugins --no-scripts phpunit/phpunit
RUN composer global require --no-plugins --no-scripts phpunit/dbunit
RUN composer global require --no-plugins --no-scripts phploc/phploc
RUN composer global require --no-plugins --no-scripts phpmd/phpmd
RUN composer global require --no-plugins --no-scripts simpletest/simpletest


# Fix for Let's Encrypt root certificate failure
RUN sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
RUN update-ca-certificates

ENV PATH /root/.composer/vendor/bin:$PATH

In addition to this change, I had to include the following line in the php.ini file:

extension=mcrypt.so

Once these changes were made mcrypt was installed properly in the php 8.1 version running on the new server.



source https://stackoverflow.com/questions/76127010/failure-to-install-pecl-mcrypt-1-0-6-on-php8-1-18-apache-using-docker-compose

No comments:

Post a Comment