Docker PHP7. x WordPress prompts that the server does not support the image rotation function

problem

Wodpress cannot cut the picture. The prompt is as follows:

Your server does not support image rotation

View the Nginx log and find the following error:

call_user_func_array() expects parameter 1 to be a valid callback, function ‘imagejpeg’ not found or invalid function name in class-wp-image-editor.php on line 420 .

solve the problem

Nginx Log Key Information function 'imagejpeg' not found

imagejpeg It is a function of the PHP GD library, which will be called when wodpress processes jpeg images.

imageXXXX Functions are generally GD library functions, and the processing methods are universal.

Check GD library support

 phpinfo();

Search GD library. If GD library supports it, it will be displayed as follows.

If the GD library is installed, check whether there is jpeg support in this column.

If the jpeg line is not displayed, it means that there is no jpeg library in GD.

It doesn't matter if the GD library is not installed. The following steps will recompile the GD library.

Install the jpeg library and other libraries

My php7 is installed on alpine linux , use apk to install the software.

Enter the container and execute the installation command.

 #Freetype library, jpeg library and png library are installed here. Select as required $ apk add --update --no-cache \ freetype-dev \ libjpeg-turbo-dev \  libpng-dev

Installed freetype , libjpeg-turbo-dev , libpng-dev

Add GD library compilation options

 $ docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

Recompile and install GD library

 $ docker-php-ext-install gd

(Optional) Install imagick support

Sometimes, WordPress will choose between GD and imagick to perform image operations.

Of course, only installing the GD library is OK.

 $ apk add --update --no-cache autoconf g++ imagemagick-dev libtool make pcre-dev $ pecl install imagick $ docker-php-ext-enable imagick $ apk del autoconf g++ libtool make pcre-dev

The imagick extension is installed and enabled.

Restart the PHP container

Exit to the host and restart the PHP container with the following command.

 Docker restart f12da14123 (container id obtained by using docker ps)

References

  1. [Header] [Docker, Inc.】Docker Docker Logo
  2. [Script] [Github] m2sh PHP7>Alpine>DockerFile
Zimiao haunting blog (azimiao. com) All rights reserved. Please note the link when reprinting: https://www.azimiao.com/4903.html
Welcome to the Zimiao haunting blog exchange group: three hundred and thirteen million seven hundred and thirty-two thousand

Comment

*

*

Comment area

  1. littleplus 06-03 00:22 reply

    Can you show me this on Children's Day?

  2. c0sMx 06-24 13:27 reply

    (Eh~