GD is a PHP library which needs to be installed on the server itself. Most standard web hosting services offer it by default. This can be a little difficult if you don’t have some server management experience.
Here are some instructions to turn it on that I found online …
Installing GD Library for PHP
Here are the instructions for installing the GD library for PHP on different systems:
Linux (Ubuntu/Debian)
For PHP 7.x/8.x:
sudo apt update
sudo apt install php-gd
For specific PHP versions: For PHP 8.1
sudo apt install php8.1-gd For PHP 8.0
sudo apt install php8.0-gd For PHP 7.4
sudo apt install php7.4-gd
Linux (CentOS/RHEL/Rocky Linux)
Using yum/dnf: CentOS 7/RHEL 7
sudo yum install php-gd CentOS 8+/RHEL 8+/Rocky Linux
sudo dnf install php-gd
macOS
Using Homebrew: If you have PHP installed via Homebrew
brew install php GD is typically included by default Or reinstall with GD explicitly
brew reinstall php –with-gd
Using MacPorts:
sudo port install php81-gd
Windows
Using XAMPP/WAMP:
- GD extension is usually pre-installed and enabled
- Check your php.ini file and ensure this line is uncommented:
extension=gd
Manual installation:
- Download the appropriate PHP GD extension DLL
- Place it in your PHP extensions directory
- Add extension=gd to your php.ini file
Compiling from Source (Advanced)
If you need to compile PHP with GD support: Install GD development libraries first
sudo apt install libgd-dev libpng-dev libjpeg-dev libfreetype6-dev Configure PHP with GD support
./configure –with-gd –with-jpeg –with-png –with-freetype Compile and install
make && sudo make install
Verification
After installation, restart your web server and verify GD is working:
Restart Web Server
Don’t forget to restart your web server after installation: Apache
sudo systemctl restart apache2 or
sudo service apache2 restart Nginx with PHP-FPM
sudo systemctl restart nginx
sudo systemctl restart php-fpm or
sudo service nginx restart
sudo service php-fpm restart
Common Issues
Permission issues: Make sure your web server user has proper permissions to load the extension.
Wrong PHP version: Ensure you’re installing the GD extension for the correct PHP version your web server is using.
Missing dependencies: On some systems, you might need additional image libraries like libjpeg, libpng, or libfreetype.
The exact installation method depends on your operating system and how PHP was installed on your system. The package manager approach (apt, yum, brew) is usually the simplest and most reliable method.