Ubuntu 14.04.2 Laravel 4.2.0 PDOException找不到驱动程序MySQL

Seu*_*Lee 5 mysql ubuntu pdo exception laravel

我没有10个声誉所以无法添加图片,抱歉.

我希望Laravel 4.2.0能够在我的Ubuntu 14.04.2 LTS服务器上运行.

我到目前为止做了什么:

  1. 安装Ubuntu 14.04.2

  2. sudo apt-get install apache2

  3. sudo apt-get install mysql-server

  4. 安装Openssl

  5. 安装libmcrypt

  6. 安装PHP

       ./configure --with-openssl --with-mcrypt --enable-mbstring --with-pdo-mysql --enable-pdo --with-mysql
    
    Run Code Online (Sandbox Code Playgroud)

    make make install

  7. 从GitHub下载Laravel 4.2.0 zip文件,解压缩并通过WinSCP传输

  8. 安装Laravel 4.2.0

    curl -sS https://getcomposer.org/installer | php php composer.phar安装

  9. 通过配置/app/config/database.php来建立数据库连接

    'mysql'=> array('driver'=>'mysql','host'=>'localhost','database'=>'laravel','username'=>'laravel-user','password'=> '************','charset'=>'utf8','collat​​ion'=>'utf8_unicode_ci','prefix'=>'',),

我收到了这个错误.

PDOException
could not find driver

Open: /var/www/laravel/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php
     */
    public function createConnection($dsn, array $config, array $options)
    {
        $username = array_get($config, 'username');

        $password = array_get($config, 'password');

        return new PDO($dsn, $username, $password, $options);
    }
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么办.我用Google搜索了一天,但没有回答.请帮我.

我检查了使用php -i|grep PDO命令启用的PDO .

结果:

PDO support => enabled
PDO drivers => sqlite, mysql
PDO Drivers for MySQL => enabled
PDO Drivers for SQLite 3.x => enabled
Run Code Online (Sandbox Code Playgroud)

但我检查了php.ini,没有像extension = pdo.so 那样的行所以我添加了这样的行

[Pdo]
; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off"
; http://php.net/pdo-odbc.connection-pooling
;pdo_odbc.connection_pooling=strict

;pdo_odbc.db2_instance_name

[Pdo_mysql]
; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/pdo_mysql.cache_size
pdo_mysql.cache_size = 2000

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket=

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
Run Code Online (Sandbox Code Playgroud)

请帮助我摆脱这种令人沮丧的情况..谢谢你提前帮助我.

小智 0

这意味着您还没有安装扩展。

使用以下命令安装它: 你的 php 版本在sudo apt-get install phpx.x-mysql 哪里,例如: 或者尝试: x.xphp5.6-mysqlsudo apt-get install php-mysql