找到你要的答案

Q:Zend PDO issue after Ubuntu 15.04

Q:Zend PDO的问题后,Ubuntu 15.04

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

我有一个灯在Ubuntu设置服务器。许多Magento和MediaWiki安装之前我升级到Ubuntu 15.04的好工作。

升级后,试图加载一个网页是我本地引发错误的PDO扩展该适配器需要但推广不加载

我把PHP米看到PDO和pdo_mysql都装。我的PHP版本是5.6.4。该设备没有使用一个个人的php.ini文件。我试图添加

extension=pdo.so
extension=pdo_mysql.so

在/ etc /开发/要/的但这丝毫不影响我的情况。我还发现安装PHP5 MySQL最新版本。

有没有人看到这个问题?这是具体到Ubuntu的升级,或者我只是缺少一个配置设置的地方吗?

编辑:PHP信息

读Lea的答案后,我到哪里,我| grep php我PDO产生输出点:

/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

测试脚本也成功运行。

answer1: 回答1:

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

Install

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

Load Modules (sudo vim /etc/php5/apache2/php.ini)

extension=pdo.so
extension=pdo_mysql.so

Restart Apache

sudo service apache2 restart or /etc/init.d/apache2 restart

Check if module are enabled (make sure the modules are loaded)

  1. Create a php file and add:

    <?php phpinfo();?>

  2. Or run

    php -i | grep pdo

Testing

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();
}

我知道你已经这一切的步骤。然而,一步一步地遵循这个指南。有时我们错过了一些小步。这对我有用。我只测试了它在使用Ubuntu 15.04虚拟机

Install

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

Load Modules (sudo vim /etc/php5/apache2/php.ini)

extension=pdo.so
extension=pdo_mysql.so

Restart Apache

sudo apache2重启服务或/及其他/ init.d/apache2重启

Check if module are enabled (make sure the modules are loaded)

  1. 创建一个PHP文件并添加:

    和?PHP phpinfo();?& gt;

  2. 或运行

    PHP -我| grep PDO

Testing

改变你的名称,用户名和密码匹配您的设置。

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();
}
php  ubuntu  pdo