Open a terminal window on your Ubuntu machine.
Update the package list by running the following command:
sudo apt-get update
- Install the PHP GD package by running the following command:
sudo apt-get install php-gd
- After the installation is complete, restart the Apache web server by running the following command:
sudo systemctl restart apache2
- Verify the installation by creating a simple PHP script that uses the GD library. For example, you can create a script called test.php with the following code:
- Save the script in the /var/www/html directory and access it in a web browser by navigating to http://localhost/test.php. If the script displays a "Hello, world!" message in a PNG image, the installation was successful.