【发布时间】:2015-06-16 23:28:26
【问题描述】:
我没有 10 声望,所以无法添加图片,抱歉。
我希望 Laravel 4.2.0 在我的 Ubuntu 14.04.2 LTS 服务器上运行。
到目前为止我做了什么:
安装 Ubuntu 14.04.2
sudo apt-get install apache2sudo apt-get install mysql-server安装 Openssl
安装 libmcrypt
-
安装 PHP
./configure --with-openssl --with-mcrypt --enable-mbstring --with-pdo-mysql --enable-pdo --with-mysql制作 进行安装
从 GitHub 下载 Laravel 4.2.0 zip 文件,解压并通过 WinSCP 传输
-
通过
安装 Laravel 4.2.0curl -sS https://getcomposer.org/installer | php php composer.phar 安装
-
通过配置/app/config/database.php连接数据库
'mysql' => 数组( '驱动程序' => 'mysql', '主机' => '本地主机', '数据库' => 'laravel', '用户名' => 'laravel 用户', '密码' => '************', '字符集' => 'utf8', '排序规则' => 'utf8_unicode_ci', '前缀' => '', ),
我得到了这个错误。
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);
}
我不知道该怎么办。 我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
但是我检查了 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
请帮助我摆脱这种令人沮丧的情况.. 提前感谢您对我的帮助。
【问题讨论】:
-
将此代码放入您的 routes.php goo.gl/gkZm8V 中。然后转到
/phpinfo,请检查 PDO 支持部分是否有mysql。
标签: mysql exception ubuntu laravel pdo