Skip to content

Instantly share code, notes, and snippets.

@angelorocha
Created April 18, 2023 15:10
Show Gist options
  • Save angelorocha/d2c31ff0f0842a897d409f28483505c9 to your computer and use it in GitHub Desktop.
Save angelorocha/d2c31ff0f0842a897d409f28483505c9 to your computer and use it in GitHub Desktop.
Install php gd on centos 7 with php 8.1.10

Go to:

cd /usr/src

Download php binaries:

wget https://www.php.net/distributions/php-8.1.10.tar.gz

Extract files:

tar zxvf php-8.1.10.tar.gz

Go to:

cd php-8.1.10/ext/gd

Install dependencies:

  • sudo yum install gcc libpng-devel libjpeg-turbo-devel libjpeg-devel libwebp-devel libXpm-devel freetype-devel libavif-devel

Add paths:

export C_INCLUDE_PATH=/usr/include/freetype2

export PKG_CONFIG_PATH=/usr/lib64/pkgconfig

Execute:

  • phpize
  • ./configure --with-php-config=/usr/bin/php-config --with-jpeg --with-webp --with-avif --with-xpm --with-freetype
  • make
  • sudo make install

Copy the file:

sudo cp modules/gd.so /usr/lib64/php/modules/

Create a file on:

  • /etc/php.d/gd.ini

Add the line:

  • extension=gd.so

Restart apache and php-fpm

  • sudo service httpd restart && sudo serviec php-fpm restart

Check the loaded php modules:

  • php -m

Enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment