PHP Fatal error: Call to undefined function imagettftext()

后端 未结 5 1753
感动是毒
感动是毒 2020-12-05 09:58

Why am I getting the error PHP Fatal error: Call to undefined function imagettftext() on line 29?



        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 10:32

    I solve the same issue on my docker php:7-fpm enviroment, and I post the solution here:


    If using Dockerfile to setup the enviroment

    # more Dockerfile  
    FROM php:fpm 
    RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
            libmcrypt-dev \
            libpng12-dev \
            libjpeg-dev \
            libpng-dev
        && docker-php-ext-install iconv mcrypt \
        && docker-php-ext-configure gd \
            --enable-gd-native-ttf \
            --with-freetype-dir=/usr/include/freetype2 \
            --with-png-dir=/usr/include \
            --with-jpeg-dir=/usr/include \
        && docker-php-ext-install gd \
        && docker-php-ext-install mbstring \
        && docker-php-ext-enable gd
    

    If want to add the FreeType module on an exist container:

    # on docker host machine
    docker exec -it $FPM_CONTAINER bash
    
    >>>>
    
    # inside the container
    apt-get install -y \
            libfreetype6-dev \
            libmcrypt-dev \
            libpng12-dev \
            libjpeg-dev \
            libpng-dev
    docker-php-ext-configure gd \
            --enable-gd-native-ttf \
            --with-freetype-dir=/usr/include/freetype2 \
            --with-png-dir=/usr/include \
            --with-jpeg-dir=/usr/include \
        && docker-php-ext-install gd
    
    exit
    
    <<<<
    
    docker restart $FPM_CONTAINER
    

提交回复
热议问题