How to Install PHP GD Support for Apache on Ubuntu
Works with Ubuntu 18.04, 20.04, 22.04, 24.04+ and supports PHP 7.x / 8.x
Step 1: Update Your Package List
Start by updating your system's package index:
Step 2: Install Apache (If Not Already Installed)
If you haven’t installed Apache yet:
You can check if Apache is running:
Step 3: Install PHP (If Not Already Installed)
To install PHP (example with PHP 8.1, change if needed):
Check PHP version:
Step 4: Install PHP GD Library
Install the PHP GD module:
If you’re using a specific PHP version (like PHP 8.1), use:
Step 5: Restart Apache
After installing the GD module, restart Apache to apply changes:
Step 6: Verify GD Installation
To confirm GD is enabled, create a phpinfo()
file:
Add this content:
Then visit:http://localhost/info.php
Look for "GD Support" in the browser page.
If you see it listed, GD is successfully installed!
(Optional) Step 7: Remove the Test File
For security, delete the info.php
file after testing:
Done!
You’ve now installed PHP GD support on Apache in Ubuntu! You’re ready to process images using PHP functions like imagecreatefromjpeg()
, imagepng()
, imagecopyresampled()
, etc.