I try to install mcrypt in my docker image based on php:7.2-apache. Therefore I use the RUN-Command from the documentation and also answerd here but I receive this error:
error: /usr/src/php/ext/mcrypt does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see docker-php-ext-configure
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev && docker-php-ext-install -j$(nproc) iconv mcrypt gd mbstring zip' returned a non-zero code: 1
My Dockerfile:
FROM php:7.2-apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt gd mbstring zip
# && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
# && docker-php-ext-install -j$(nproc) gd
COPY ./etc/000-default.conf /etc/apache2/sites-available/
EXPOSE 80
Has anybody an idea how to solve or how to get the needed files in the requested folder?
Thanks!
mcrypt extension is not provided with the PHP source since 7.2 , but are instead available through PECL. To install a PECL extension in docker, use pecl install to download and compile it, then use docker-php-ext-enable to enable it:
pecl install mcrypt-1.0.5
docker-php-ext-enable mcrypt
Before the pecl install you may need to install/update the package libmcrypt-dev
apt-get update && apt-get install -y libmcrypt-dev
Building on MoiioM's answer, this worked for me using the 7.2-stretch Docker image from PHP
RUN apt-get update && apt-get install -y libmcrypt-dev \
&& pecl install mcrypt-1.0.4 \
&& docker-php-ext-enable mcrypt
To install mcrypt extension you have to make sure you did install libmcrypt-dev which is required.
Try to add:
RUN apt install libmcrypt-dev
before you are trying to install extensions for php.
Update
Try to run first:
docker-php-ext-configure mcrypt
and then
docker-php-ext-install mcrypt
Related
I have this Dockerfile:
FROM php:8.1.0-fpm
RUN apt-get update \
&& apt-get install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip libpng-dev libssl-dev libxslt-dev wkhtmltopdf procps acl \
&& pecl install apcu \
&& docker-php-ext-install intl opcache pdo pdo_mysql zip gd xsl -j$(nproc) \
&& docker-php-ext-enable apcu opcache \
&& docker-php-ext-configure zip
# xmlrpc
# channel://pecl.php.net/xmlrpc-1.0.0RC3
# php-xmlrpc
# php-xml-rpc
# php8.1-xmlrpc
# php-pecl-xmlrpc
# php81-pecl-xmlrpc
# xmlrpc-1.0.0RC3
I've tried so many ways to include XML-RPC in there (c.f. commented lines) but nothing's working. I know it's not recommended to use this package but it's a dependency that I absolutely need. It worked fine in PHP 7.4, but I can't figure it out for PHP 8.1.
Can anyone clue me in please?
Add this command
RUN pecl install channel://pecl.php.net/xmlrpc-1.0.0RC3 xmlrpc
and do not forget to add "extension=xmlrpc.so" to php.ini file.
I would like to install the ext-http extension because I have this error when I execute composer install command in my php-apache container:
The requested PHP extension ext-http * is missing from your system.
Install or enable PHP's http extension.
My Dockerfile:
ARG PHP_VERSION=""
FROM php:${PHP_VERSION}-apache
ENV COMPOSER_ALLOW_SUPERUSER=1
EXPOSE 80
WORKDIR /${PROJECT_DIRECTORY}
# git, unzip & zip are for composer
RUN apt-get update -qq && \
apt-get install -qy \
git \
gnupg \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libicu-dev \
libxml2-dev \
wget \
nano \
unzip \
zip && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# PHP Extensions
RUN docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap
ADD php/php.ini /usr/local/etc/php/conf.d/${PROJECT_DIRECTORY}.ini
# Apache
RUN a2enmod rewrite remoteip
ADD vhosts/vhost.conf /etc/apache2/sites-available/000-default.conf
I have "ext-http": "*" in require node of my composer.json.
I tried:
RUN docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap ext-http
And I have this error:
Step 7/10 : RUN docker-php-ext-install -j$(nproc) opcache pdo_mysql
intl xml soap ext-http ---> Running in 8ef2c127b632 error:
/usr/src/php/ext/ext-http does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name
...] ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see
docker-php-ext-configure
Possible values for ext-name: bcmath bz2 calendar ctype curl dba dom
enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv imap
intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib
pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql
phar posix pspell readline reflection session shmop simplexml snmp
soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy
tokenizer xml xmlreader xmlrpc xmlwriter xsl zend_test zip
Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded. ERROR:
Service 'apache' failed to build: The command '/bin/sh -c
docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap
ext-http' returned a non-zero code: 1 Failed to deploy 'Compose:
.docker': docker-compose process finished with exit code 1
How can I install this extension please?
I published a script that lets you install the http PHP extension (and many others) with just these lines:
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions http
the script takes care of the PHP version, and installs all the required APT (for Debian) or APK (for Alpine) packages.
More details here: https://github.com/mlocati/docker-php-extension-installer
You might want to install it via pecl. The http extension also has dependencies.
RUN docker-php-ext-install hash iconv \
&& pecl install raphf propro \
&& docker-php-ext-enable raphf propro \
&& pecl install pecl_http \
&& echo -e "extension=raphf.so\nextension=propro.so\nextension=http.so" > /usr/local/etc/php/conf.d/docker-php-ext-http.ini \
&& rm -rf /usr/local/etc/php/conf.d/docker-php-ext-raphf.ini \
&& rm -rf /usr/local/etc/php/conf.d/docker-php-ext-propro.ini
I've got the inspiration via https://hub.docker.com/r/realpaul/docker-php/dockerfile
Why are the modules not loaded?
This is my Dockerfile:
FROM php:5.6-apache
# Install PHP extensions and PECL modules.
RUN buildDeps=" \
libbz2-dev \
libmemcached-dev \
libmysqlclient-dev \
libsasl2-dev \
" \
runtimeDeps=" \
curl \
git \
libfreetype6-dev \
libicu-dev \
libjpeg-dev \
libldap2-dev \
libmcrypt-dev \
libmemcachedutil2 \
libpng12-dev \
libpq-dev \
libxml2-dev \
" \
&& apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y $buildDeps $runtimeDeps \
&& docker-php-ext-install bcmath bz2 calendar iconv intl mbstring mcrypt mysql mysqli opcache pdo_mysql pdo_pgsql pgsql soap zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \
&& docker-php-ext-install exif \
&& pecl install memcached-2.2.0 redis \
&& docker-php-ext-enable memcached.so redis.so \
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -r /var/lib/apt/lists/* \
&& a2enmod rewrite
RUN a2enmod rewrite
RUN usermod -u 1000 www-data
RUN usermod -G staff www-data
And this is the output from php -m:
root#3363bf2aa56d:/var/www/html# php -m
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xsl.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/xsl.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
hash
iconv
intl
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
For example, there is no calendar extension, but it is defined in the Dockerfile itself. Also, exif doesn't appear in the list. Whats wrong here?
Solution was, that the php.ini hasn't been updated accordingly.
...
extension=gd.so
extension=calendar.so
extension=exif.so
extension=xdebug.so
extension=soap.so
extension=opcache.so
...
Now it works.
You can add a command in the Dockerfile to activate the extension after building. For example, to enable the calendar extension add:
RUN php5enmod calendar
I would like to deploy my Laravel project with GitLabCI and docker. I have a yaml file with the following before_script:
docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache
Its return with this:
error: /usr/src/php/ext/mcrypt does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see docker-php-ext-configure
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
Some of the above modules are already compiled into PHP; please check
the output of "php -i" to see which modules are already loaded.
ERROR: Job failed: exit code 1
I tried to install manually the mcrypt with apt-get install following these answers, but nothing worked for me. Cheked this forum post too, but there is no mentioned about this error.
gitlab-ci.yaml file:
before_script:
# Update packages
- apt-get update -yqq
- apt-get install -my wget gnupg
# Upgrade to Node 7
- curl -sL https://deb.nodesource.com/setup_7.x | bash -
# Install dependencies
- apt-get install bzip2 git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
# Install php extensions
- docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache
# Install Node dependencies.
# comment this out if you don't have a node dependency
- npm install
- npm install -g bower
- npm install -g gulp-cli
# Install Composer and project dependencies.
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
Using php7.0 and Laravel 5.3.2
I ran into this issue. Mcrypt was deprecated in PHP 7.2. Here's how to get around it now:
image: php:7.2
before_script:
# Update packages
- apt-get update -yqq
# Install dependencies
- apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq
# Install php extensions
- docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache pcntl
....
# PHP 7.2 Mcrypt & pcntl
- pecl install mcrypt-1.0.1
- docker-php-ext-enable mcrypt
....
I tried to install some needed extensions for php using docker.
Here is my Dockerfile :
FROM php:7-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libsqlite3-dev \
libssl-dev \
libcurl3-dev \
libxml2-dev \
libzzip-dev \
&& docker-php-ext-install iconv json mcrypt mbstring mysql mysqli pdo_mysql pdo_sqlite phar curl ftp hash session simplexml tokenizer xml xmlrpc zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd
WORKDIR /var/www
CMD ["php7-fpm"]
And here is the error I got :
error: /usr/src/php/ext/mysql does not exist
usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
ie: /usr/local/bin/docker-php-ext-install gd mysqli
/usr/local/bin/docker-php-ext-install pdo pdo_mysql
/usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
if custom ./configure arguments are necessary, see docker-php-ext-configure
Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mcrypt mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip
ERROR: Service 'php-localdev' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev libsqlite3-dev libssl-dev libcurl3-dev libxml2-dev libzzip-dev && /usr/local/bin/docker-php-ext-install iconv json mcrypt mbstring mysql mysqli pdo_mysql pdo_sqlite phar curl ftp hash session simplexml tokenizer xml xmlrpc zip && /usr/local/bin/docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && /usr/local/bin/docker-php-ext-install gd'
returned a non-zero code: 1
Do you see any issues in my Dockerfile, or the problem is elsewhere ?
I was inspired for this Dockerfile by the php docker hub.
Thansk for your help.
In the error output, it lists the possible values for ext_name. mysql isn't listed. There is mysqli and pdo_mysql, but not mysql. Your command does include mysql, and the first line of the error seems to be complaining about that. Try taking that out and see if that works.