Установка PDO sqlite3 драйвера на Ubuntu

joomla pdo_mysql rockgallery vgkk

I was surprised to find PDO sqlite support wasn’t included by default with PHP 5 on my Ubuntu (10.04) virtual machine. You can check which drivers are available with this small snippet of code (assuming you run this from the command line):

foreach (PDO::getAvailableDrivers() as $driver) {    echo $driver . PHP_EOL;}

Update: Long story short, I tried the following command on this web server and it worked without any hiccups. Try this first and see where it gets you, the rest of the article may dig you out of a hole if things break.

$ sudo apt-get install php5-sqlite

For whatever reason, my local Ubuntu VM I develop on had some issues, I originally wrote this blog post around the problems I encountered then.

I initially tried installing the php5-sqlite package:

$ sudo apt-get install php5-sqlite

This appeared to install successfully but did not enable the sqlite driver in PHP. I then tried to install the sqlite driver via PECL but this failed to install both pdo and pdo_sqlite.

$ sudo pecl install pdo
...
make: *** [pdo_dbh.lo] Error 1
ERROR: `make' failed
$ sudo pecl install pdo_sqlite
...
configure: error: Cannot find php_pdo_driver.h.
ERROR: `/tmp/pear/temp/PDO_SQLITE/configure' failed

Это говорит о том, что нарушена текущая установка pdo драйвера.

Для решения проблемы надо переустановить компоненты php5.

$ apt-get --purge remove php5
$ sudo apt-get install php5 php5-sqlite php5-mysql
$ sudo apt-get install php-pear php-apc php5-curl
$ sudo apt-get autoremove

Installing PDO sqlite3 support on Ubuntu