Hi
I’m trying to build an image with PHP 8.1 and Apache + mysqli + GD
I have a problem with GD. Mysqli works but GD doesn’t work.
My sample Dockerfile is below. It is based on https://hub.docker.com/_/php
The image builds and runs, but GD does not work.
For example, I have an error
Fatal error: Uncaught Error: Call to undefined function imagecreatetruecolor() in /var/www/html/testgd.php:5 Stack trace: #0 {main} thrown in /var/www/html/testgd.php on line 5
Please give me some tips. Thank you in advance.
FROM php:8.1-apache
RUN docker-php-ext-configure mysqli \
&& docker-php-ext-install -j$(nproc) mysqli
RUN apt-get update && apt-get install -y \
libfreetype-dev \
libjpeg62-turbo-dev \
libpng-dev
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-enable gd
RUN /usr/sbin/a2enmod rewrite
Thank you for checking.
I try for example with such file testgd.php
<?php
var_dump(gd_info());
?>
The result is Fatal error*: Uncaught Error: Call to undefined function gd_info() in /var/www/html/testgd.php:3 Stack trace: #0 {main} thrown in /var/www/html/testgd.php on line *3
Also when invoking phpinfo() there is no GD information table with options like in case of other modules.
Webmaster also can not operate on images in wordpress.
Yes it does, at least from command line. If Apache HTTPD can’t use it, it probably loads the configurations from somewhere else and you need to enable GD for HTTPD too. I usually use PHP FPM, so I’m not sure how the Apache variant is built if it is different.