I have a LAMP server set up on Ubuntu. Many Magento and MediaWiki installations were working well before I upgraded to Ubuntu 15.04.
After the upgrade, attempting to load one of the pages served by my localhost raises the error The PDO extension is required for this adapter but the extension is not loaded
I typed php -m
and saw that PDO
and pdo_mysql
are both loaded. My php version is 5.6.4. None of the installations use an individual php.ini file. I tried to add
extension=pdo.so
extension=pdo_mysql.so
to /etc/php5/apache2/php.ini but this did not affect my situation. I have also verified that the latest version of php5-mysql is installed.
Has anyone else seen this problem? Is it specific to the Ubuntu upgrade, or am I just missing a configuration setting somewhere?
Edit: php info
After reading Lea's answer below, I am to the point where php -i | grep -i pdo
php -i | grep -i pdo
produces the output:
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
PDO
PDO support => enabled
PDO drivers => mysql
pdo_mysql
PDO Driver for MySQL => enabled
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
The test script also runs successfully.
I know you already this all of these steps. However; follow step by step this guide. Sometimes we missed some little step. This works for me. I just tested it in a virtual machine using Ubuntu 15.04
apt-get -y update
add-apt-repository ppa:ondrej/php5-5.6
apt-get -y update
apt-get -y install php5 php5-mhash php5-mcrypt php5-curl php5-cli php5-mysql php5-gd php5-intl
sudo vim /etc/php5/apache2/php.ini
) extension=pdo.so
extension=pdo_mysql.so
sudo service apache2 restart
or /etc/init.d/apache2 restart
Create a php file and add:
<?php phpinfo();?>
Or run
php -i | grep pdo
Change your myDatabase
, username
and password
that match your settings.
try {
$conn = new PDO('mysql:host=localhost;dbname=myDatabase', $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.