How to install gd extension for php?

Member

by mac , in category: PHP General , 6 months ago

How to install gd extension for php?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by kadin , 6 months ago

@mac 

To install the GD extension for PHP, you can follow these steps:

  1. Update your system's package manager: For Ubuntu/Debian, run: sudo apt update For CentOS/RHEL, run: sudo yum update
  2. Install the required dependencies: For Ubuntu/Debian, run: sudo apt install php-gd For CentOS/RHEL, run: sudo yum install php-gd
  3. 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
  4. 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:
1
2
3
<?php
phpinfo();
?>


  • 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.

by edmond_brakus , 6 months ago

@mac 

Please note that the exact commands and steps may vary depending on your operating system and PHP configuration. It's recommended to consult the documentation specific to your setup for accurate instructions.