How can I install the Mosquitto-php in Laradock - php

Mosquitto-php extension: https://github.com/mgdm/Mosquitto-PHP.
I tried to add 2 below commands in the laradock/php-fpm/Dockerfile, but it didn't
work.
apt-get install libmosquitto-dev && \
pecl install Mosquitto-alpha
please give me some advices, thanks.

Try add this in dockerfile:
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev libxml2-dev libcurl4-gnutls-dev \
libmosquitto-dev # edit
RUN docker-php-ext-install -j$(nproc) mysqli mbstring pdo pdo_mysql soap curl \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& pecl install xdebug && docker-php-ext-enable xdebug \
&& pecl install Mosquitto-alpha && docker-php-ext-enable Mosquitto-alpha

Related

Installing php7.3:GD ext Freetype and JPEG Support

I'm new in docker and im trying to install GD extension with freetype and jpeg support , but when installed , always like this...
[GD Version] => bundled (2.1.0 compatible)
[FreeType Support] =>
[GIF Read Support] => 1
[GIF Create Support] => 1
[JPEG Support] =>
[PNG Support] => 1
[WBMP Support] => 1
[XPM Support] =>
[XBM Support] => 1
[WebP Support] =>
[BMP Support] => 1
[JIS-mapped Japanese Font Support] =>
jpeg and freetype doesn't want to be installed
btw this is my docker file
app.dockerfile
FROM php:7.3-fpm-buster
RUN sed -i 's/9000/3004/' /usr/local/etc/php-fpm.d/zz-docker.conf
RUN apt-get update && apt-get install -y libpq-dev git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libwebp-dev \
libldap2-dev \
libmagickwand-dev \
libgd3 \
libgd-dev \
zlib1g-dev \
libzip-dev \
--no-install-recommends && apt-get clean && rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
&& docker-php-ext-install ldap gd pdo pdo_pgsql pgsql intl pcntl zip bcmath \
&& docker-php-ext-install gd \
&& docker-php-ext-install exif \
&& pecl install redis && docker-php-ext-enable redis \
&& pecl install imagick && docker-php-ext-enable imagick
RUN ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata
## imagemagick sepertinya belum berjalan dengan lancar di php8 (05 Feb 2021)
## https://github.com/Imagick/imagick/issues/331
## -------------------------------------------------------------------------
COPY ./docker/php.ini /usr/local/etc/php/php.ini
WORKDIR /var/www
USER nobody
queue.dockerfile
FROM php:7.3-cli-buster
RUN apt-get update && apt-get install -y libpq-dev git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libwebp-dev \
libldap2-dev \
libmagickwand-dev \
libgd3 \
libgd-dev \
zlib1g-dev \
libzip-dev \
--no-install-recommends && apt-get clean && rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
&& docker-php-ext-install ldap gd pdo pdo_pgsql pgsql intl pcntl zip bcmath \
&& docker-php-ext-install gd \
&& docker-php-ext-install exif \
&& pecl install redis && docker-php-ext-enable redis \
&& pecl install imagick && docker-php-ext-enable imagick
## imagemagick sepertinya belum berjalan dengan lancar di php8 (05 Feb 2021)
## https://github.com/Imagick/imagick/issues/331
## -------------------------------------------------------------------------
RUN ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata
COPY ./docker/php.ini /usr/local/etc/php/php.ini
WORKDIR /var/www
USER nobody
entrypoint ["php", "artisan", "queue:work", "--sleep=3", "--tries=3", "--max-time=1800"]
composer.dockerfile
FROM php:7.3-cli-buster
COPY --from=composer/composer /usr/bin/composer /usr/bin/composer
RUN apt-get update && apt-get install -y libpq-dev git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libwebp-dev \
libldap2-dev \
libmagickwand-dev \
libgd3 \
libgd-dev \
zlib1g-dev \
libzip-dev \
unzip \
--no-install-recommends && apt-get clean && rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
&& docker-php-ext-install pdo pdo_pgsql pgsql intl pcntl zip bcmath \
&& docker-php-ext-install gd \
&& docker-php-ext-install exif \
&& pecl install redis && docker-php-ext-enable redis \
&& pecl install imagick && docker-php-ext-enable imagick
# imagemagick sepertinya belum berjalan dengan lancar di php8 (05 Feb 2021)
# https://github.com/Imagick/imagick/issues/331
# -------------------------------------------------------------------------
WORKDIR /app
CMD ["composer"]
if i may know what could be the problem and how could I fix it?
Seems to me that Dockerfile should looks like this:
FROM php:7.3-fpm-buster
# Install dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
jpegoptim optipng pngquant gifsicle
RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev
RUN pecl install imagick && docker-php-ext-enable imagick
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* || true
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-install gd
RUN docker-php-ext-install gd

PHP Graphical Library with Docker in Ubuntu

I have Docker with php and mysqli, and I'm trying to put the graphical library in my Ubuntu 20.04.3 LTS.
These are the lines in my PHP.Dockerfile:
FROM php:fpm
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN docker-php-ext-install pdo pdo_mysql
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg-dev \
libpng-dev \
libonig-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd \
&& docker-php-ext-enable gd
RUN pecl install xdebug && docker-php-ext-enable xdebug
When i run Docker-Compose up and open the php file with the captcha it shows me that fail. The refered lines are the ones of the captcha.
All my partners use Linux Mint, and it works in their machines, so i dont know why it doesnt work in my Ubuntu
Does someone know what am I doing wrong? I dont know what to do to run the graphical librarys (for captchas, graphics...) with docker
SOLVED:
I changed the old PHP.Dockerfile file and now it works!!
The problem was the version PHP in Ubuntu.
First I deleted all the *.pem from mysqldata, and then I used this lines in the PHP.Docker
FROM php:7.4-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN docker-php-ext-install pdo pdo_mysql
RUN pecl install xdebug && docker-php-ext-enable xdebug
Then I executed docker-compose build. And all is good now

docker php how to install event or libevent?

I write a dockerfile
FROM php:7.2-cli
RUN curl -fsSL 'http://pecl.php.net/get/event-2.3.0.tgz' -o event.tgz \
&& mkdir -p event \
&& tar -xf event.tgz -C event --strip-components=1 \
&& rm event.tgz \
&& ( \
cd event \
&& phpize \
&& ./configure --with-php-config=/usr/local/php/bin --with-event-libevent-dir=/usr/local/libevent-2.1.8/ \
&& make -j "$(nproc)" \
&& make install \
) \
&& rm -r event \
&& docker-php-ext-enable event
RUN docker-php-ext-install -j$(nproc) pcntl \
#&& pecl install event-2.4.2 \
#&& docker-php-ext-configure event --with-event-libevent-dir=/usr/local/libevent-2.4.2/ \
&& docker-php-ext-enable pcntl
but it no work well.
configure: error: Cannot find php-config. Please use --with-php-config=PATH
I want use php pecl extensions event or libevent, how should I do? thank you!
The following docker file worked for me:
FROM php:7.2-cli
RUN docker-php-ext-install sockets \
&& apt-get update && apt-get -y install libevent-dev libssl-dev libjpeg-dev libpng-dev \
&& pecl channel-update pecl.php.net && pecl install event-2.4.2 && docker-php-ext-enable event \
&& docker-php-ext-install -j$(nproc) pcntl mysqli

Troubles with Docker + PHP7 + GD resulting in "Call to undefined function imagecreatefromjpeg()"

I'm having troubles when trying to create an image using imagecreatefromjpeg using this Dockerfile to generate the container:
FROM php:7.1-apache
RUN apt-get update && \
apt-get install -y -qq git \
libjpeg62-turbo-dev \
apt-transport-https \
libfreetype6-dev \
libmcrypt-dev \
libpng12-dev \
libssl-dev \
zip unzip \
nodejs \
npm \
wget \
vim
RUN pecl install redis && docker-php-ext-enable redis
RUN docker-php-ext-install -j$(nproc) iconv mcrypt zip pdo pdo_mysql gd bcmath
COPY ./containers/yii.conf /etc/apache2/sites-available/000-default.conf
RUN for mod in rewrite headers; do a2enmod $mod; done && service apache2 restart
WORKDIR /var/www/html/
GD was correctly installed (libjpeg too - both appearing in php -i and phpinfo()) but imagecreatefromjpeg does not works and I don't know why.
I also ran apt install libjpeg-dev libpng-dev libfreetype6-dev trying to ~force~ reinstallation (or reconfiguration) but seems doesn't succeded (yes, I also restart the container).
root#e8db647c96c4:/var/www/html# php -i | grep -i GD
/usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
gd
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
gd.jpeg_ignore_warning => 1 => 1
root#e8db647c96c4:/var/www/html#
root#e8db647c96c4:/var/www/html# docker-php-ext-enable gd
warning: gd (gd.so) is already loaded!
root#e8db647c96c4:/var/www/html#
I've tried apt install libgd2-xpm-dev* and apparently it doesn't solves the problem.
Solved
I was missing to put
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) gd
into my Dockerfile.
Full revised Dockerfile:
FROM php:7.1-apache
RUN apt-get update && \
apt-get install -y -qq git \
libjpeg62-turbo-dev \
apt-transport-https \
libfreetype6-dev \
libmcrypt-dev \
libpng12-dev \
libssl-dev \
zip unzip \
nodejs \
npm \
wget \
vim
RUN pecl install redis && docker-php-ext-enable redis
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) iconv mcrypt zip pdo pdo_mysql gd bcmath
COPY ./containers/yii.conf /etc/apache2/sites-available/000-default.conf
RUN for mod in rewrite headers; do a2enmod $mod; done && service apache2 restart
WORKDIR /var/www/html/
PHP 7.4 (Alpine)
If anybody is struggling to enable JPEG support in GD with PHP 7.4, here's what I had to do in order to be able to use imagecreatefromjpeg() function.
My example is based on Alpine 3.10, if you're using other distribution adjust it to your needs.
First install dependencies, in my case beside JPEG I need support for PNG files.
apk add jpeg-dev libpng-dev
After that we can run docker-php-ext-configure command to configure our gd with JPEG support. Notice that flag --with-jpeg-dir was changed to --with-jpeg and we don't need to provide flag to enable PNG. More you can read in PHP 7.4 Changelog in GD section.
docker-php-ext-configure gd --with-jpeg
Directly after that let's run docker-php-ext-install to install GD itself.
docker-php-ext-install -j$(nproc) gd
FULL EXAMPLE
FROM php:7.4-fpm-alpine3.10
RUN apk add jpeg-dev libpng-dev \
&& docker-php-ext-configure gd --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
For PHP 5.6
FROM php:5.6-apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev libjpeg62-turbo-dev \
libgd-dev libpng12-dev
RUN docker-php-ext-configure gd \
--with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd
If still not working, can re-install the container.
docker rm <container id>
docker-compose build --pull
docker-compose up
Updated Version PHP 7.4 + Apache:
Dockerfile
FROM php:7.4-apache
RUN apt-get update -y && apt-get install -y sendmail libpng-dev libfreetype6-dev libjpeg62-turbo-dev libgd-dev libpng-dev
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-configure gd \
--with-freetype=/usr/include/ \
--with-jpeg=/usr/include/
RUN docker-php-ext-install gd
...
Add these Commands
docker-php-ext-configure gd --with-freetype --with-jpeg
docker-php-ext-install -j$(nproc) gd
Working full Dockerfile:
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /src/
# Set working directory
WORKDIR /src
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libxpm-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo_mysql exif pcntl
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install --prefer-source --no-interaction
COPY . /src
RUN chmod 777 -R /src/storage
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

Docker gd module for PHP 7

I've got docker file, which is configured for Drupal 8, but after I fired up "docker-compose up", everything went smooth but in installation of Drupal it's showing me that "gd" module for PHP is not enabled.
here is my Dockerfile:
FROM php:7-fpm
# Install modules
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN DEBIAN_FRONTEND="noninteractive" add-apt-repository ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y vim curl wget build-essential software-properties-common git ca-certificates
RUN apt-get install -y \
libbz2-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
libxpm-dev \
libvpx-dev \
libmcrypt-dev \
libmemcached-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure gd \
--with-freetype-dir=/usr/lib/x86_64-linux-gnu/ \
--with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \
--with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \
--with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \
&& \
docker-php-ext-install \
bcmath \
bz2 \
exif \
ftp \
gd \
gettext \
mbstring \
mcrypt \
mysqli \
opcache \
pdo_mysql \
shmop \
sockets \
sysvmsg \
sysvsem \
sysvshm \
zip \
&& \
pecl install apcu memcached && \
echo 'extension = apcu.so' > /usr/local/etc/php/conf.d/apcu.ini && \
echo 'extension = memcached.so' > /usr/local/etc/php/conf.d/memcached.ini
I try this method: Error In PHP5 ..Unable to load dynamic library
But no use
This will help you
FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
maybe should try this
# Install GD
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd
With PHP 7.2 I got the following error when trying the accepted/other answers:
E: Package 'libpng12-dev' has no installation candidate
This worked for me:
FROM php:7.2-fpm
RUN apt update \
&& apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) intl pdo_mysql bcmath mbstring exif gd
Note the change from libpng-dev12 to libpng-dev

Categories