How can the gd2 functionality be enabled in PHP on a Linux system?

To enable the gd2 functionality in PHP on a Linux system, you need to install the gd library and then enable the gd extension in the php.ini configuration file.

sudo apt-get install php-gd
sudo service apache2 restart