Enabling/installing GD extension? --without-gd

To enable the GD extension in PHP, you will need to install the extension and then enable it in your PHP configuration file.

  1. First, install the GD extension. On a Debian-based system, you can use the following command:
sudo apt-get install php-gd

On a Red Hat-based system:

sudo yum install php-gd

Watch a course Learn object oriented PHP

  1. Next, you will need to enable the extension in your PHP configuration file. This file is usually called php.ini.

Locate the line that reads ;extension=gd2 and remove the ; to uncomment the line. It should look like this:

extension=gd2
  1. Save the changes to the file and restart your web server. You can check if the extension is loaded by creating a PHP info file.

To do this, create a new file called info.php and add the following code:

Place this file in your web root directory (e.g. /var/www/html) and access it in your web browser. In the output, search for the gd section. If the extension is loaded, you will see information about it in this section.

If you installed PHP with the --without-gd flag, then the GD extension will not be compiled into PHP and you will not be able to use it. In this case, you will need to recompile PHP with the --with-gd flag.