How do I install and enable pdo_mysql and gd extensions for php5?

When trying to install webtrees I get the following output:

Checking server configuration

PHP extension "pdo_mysql" is disabled. You cannot install webtrees until this is enabled. Please ask your server's administrator to enable it.

PHP extension "gd" is disabled. Without it, the following features will not work: creating thumbnails of images. Please ask your server's administrator to enable it.

How do I install and enable the pdo_mysql and gd extensions?


Solution 1:

PHP5 plugins outside those included in a plain default install (from installing just a php5 plugin for apache, or php5-fpm or similar) will not exist, and because of that, you need to install them. From your post, I gather that you need the mysql and gd plugins. Those packages are php5-gd and php5-mysql. They can be installed with the following command:

sudo apt-get install php5-gd php5-mysql

Once complete, you will need to restart the PHP service. Depending on how it was installed, you will need to do one of the following items:

  • If you installed it via LAMP (Linux Apache, MySQL, PHP5), then you'll need to restart the entire apache instance with: sudo service apache2 restart
  • If you installed PHP from a separate service, like php5-fpm, then use sudo service php5[tab] restart (where you actually press the "tab" key where it says [tab]) After that, your php5 should have those extensions loaded.

Solution 2:

If the above answer doesn't works for you:

Just remove the version number: sudo apt-get install php-mysql

Or if you need a specific package, add the minor version: sudo apt-get install php7.0-mysql


Or check php installation:

check php version via: php -v

if an error shows up check the correct php installation.