install php70-gd on ubuntu

install php70-gd on ubuntu

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Resolving GD Library Issues on Ubuntu with PHP 7

When upgrading to PHP 7, a common stumbling block arises when attempting to enable image processing capabilities. The GD library is essential for tasks ranging from generating thumbnails to creating CAPTCHAs, yet the transition from PHP 5 to PHP 7 often breaks existing configurations due to package naming conventions and repository availability. If you find yourself unable to locate the GD extension after installing PHP 7, it is crucial to understand that the core issue usually lies in the specific Debian/Ubuntu package management system rather than a fundamental lack of support for the library itself.

The source material highlights a scenario where a user attempts to install the dependency using sudo apt-get install php70-gd or sudo apt-get install php70-php-gd. While these commands reflect a logical assumption that PHP 7 packages might retain the "php70" prefix common in older repositories, they frequently fail because modern Ubuntu releases and the official PHP packaging team have shifted away from this nomenclature. In most standard Ubuntu environments, the package structure has evolved to simply php-gd when targeting the current stable PHP version (whether 7.x or 8.x). Attempting to force an installation of a non-existent php70 variant will result in errors indicating that the requested packages cannot be found, leading developers down a rabbit hole of checking obscure third-party repositories.

The technical reality is that PHP 7 does support the GD library; it simply requires the correct package identifier for your specific Ubuntu release. For instance, on a standard Ubuntu 18.04 or 20.04 system running PHP 7.4, the correct command to enable this functionality is sudo apt-get install php-gd. This package pulls in the necessary C libraries and compiles the Zend extension specifically for the active PHP binary path. Before executing the installation, ensure that you have actually enabled the module within your PHP configuration. Even after installing the package, the extension might not load automatically if it was previously disabled or if the new installation conflicts with existing configuration files.

To verify that the library is correctly integrated after installation, you should check the active PHP modules using php -m. If gd does not appear in the list, the module may need to be explicitly enabled in the php.ini file located in /etc/php/7.x/cli/php.ini or /etc/php/7.x/fpm/php.ini, depending on your setup. You can search for and comment out any lines that disable the extension, such as ;extension=gd.

A critical pitfall to avoid is assuming that all system packages are updated simultaneously. Sometimes, the PHP binary installed via a distribution package manager (like apt) differs from the one provided by third-party repositories like Ondřej Surý's repository, which is highly recommended for production environments. Using the official distro packages often results in outdated versions of PHP 7 with limited extensions. If you are working on a project that requires specific GD features or strict versioning, adding the external repository ensures you get the most up-to-date php-gd binary compatible with the latest PHP 7 patches.

In summary, the inability to find the GD library on PHP 7 is almost exclusively a packaging convention issue rather than a compatibility problem. By correcting the package name from php70-gd to php-gd and ensuring your configuration file explicitly enables the extension, you restore full image manipulation capabilities to your application stack. This approach aligns with best practices for maintaining secure and up-to-date PHP environments on Ubuntu systems.

Our network