enable the Ondrej PHP repository by typing

$ sudo apt install software-properties-common $ sudo add-apt-repository ppa:ondrej/php

install PDO

```
#sudo apt-get install -y php7.1-mysql // for Apache
sudo apt-get install -y php-pdo-mysql // 我选择使用这一行,

  1. ``` <br />Reading package lists... Done<br />Building dependency tree<br />Reading state information... Done<br />The following packages were automatically installed and are no longer required:<br /> linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic linux-image-4.4.0-31-generic<br /> linux-image-extra-4.4.0-31-generic<br />Use 'sudo apt autoremove' to remove them.<br />The following NEW packages will be installed:<br /> php7.1-mysql<br />0 upgraded, 1 newly installed, 0 to remove and 93 not upgraded.<br />Need to get 120 kB of archives.<br />After this operation, 466 kB of additional disk space will be used.<br />Get:1 [http://ppa.launchpad.net/ondrej/php/ubuntu](http://ppa.launchpad.net/ondrej/php/ubuntu) xenial/main amd64 php7.1-mysql amd64 7.1.33-16+ubuntu16.04.1+deb.sury.org+1 [120 kB]<br />Fetched 120 kB in 1s (80.2 kB/s)<br />Selecting previously unselected package php7.1-mysql.<br />(Reading database ... 186345 files and directories currently installed.)<br />Preparing to unpack .../php7.1-mysql_7.1.33-16+ubuntu16.04.1+deb.sury.org+1_amd64.deb ...<br />Unpacking php7.1-mysql (7.1.33-16+ubuntu16.04.1+deb.sury.org+1) ...<br />Setting up php7.1-mysql (7.1.33-16+ubuntu16.04.1+deb.sury.org+1) ...<br /> <br />Creating config file /etc/php/7.1/mods-available/mysqlnd.ini with new version<br />Creating config file /etc/php/7.1/mods-available/mysqli.ini with new version <br />Creating config file /etc/php/7.1/mods-available/pdo_mysql.ini with new version<br />

参考资料:

https://www.digitalocean.com/community/questions/i-need-to-enable-pdo-mysql-in-digital-ocean-ubuntu-16-04-server-on-my-php-7-1