To install the GD extension for PHP, you can follow these steps:
- Update your system's package manager:
For Ubuntu/Debian, run: sudo apt update
For CentOS/RHEL, run: sudo yum update
- Install the required dependencies:
For Ubuntu/Debian, run: sudo apt install php-gd
For CentOS/RHEL, run: sudo yum install php-gd
- Restart the PHP service to enable the newly installed extension:
For Apache, run: sudo service apache2 restart
For Nginx, run: sudo service php-fpm restart
- Verify if GD extension is enabled. You can create a file named info.php in your web server's root directory (e.g., /var/www/html) with the following contents:
- Save the file and access it through your web browser (e.g., http://localhost/info.php)
- Search for "GD" in the output, and if you find it, the extension is successfully installed.
That's it! The GD extension should now be installed and enabled on your PHP setup.