tags:

views:

6305

answers:

4

Hi,

I am trying to install sqlite3 for php in ubuntu.

I install apt-get php5-sqlite3 and edited php.ini to include sqlite3 extension.

When I run phpinfo(); I get

SQLITE3 SQLite3 support enabled
sqlite3 library version 3.4.2

as shown above, sqlite3 is enabled. However, I get "Class SQLite3 not found" when I use

 new SQLite3("database");
+4  A: 
$ sudo apt-get install php5-cli php5-dev make
$ sudo apt-get install libsqlite3-0 libsqlite3-dev
$ sudo apt-get install php5-sqlite3
$ sudo apt-get remove php5-sqlite3
$ cd ~
$ wget http://pecl.php.net/get/sqlite3-0.6.tgz
$ tar -zxf sqlite3-0.6.tgz
$ cd sqlite3-0.6/
$ sudo phpize
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo apache2ctl restart

Ripped from the ubuntu form.

miccet
The 2nd to last command should be `sudo checkinstall` (after running `sudo apt-get install checkinstall`. Why use an OS with a package manager if you're not going to use it?
Brendan Long
+3  A: 

You probably already have it enabled. For an SQLite3 database:

new SQLite("database");

The SQLite3 PDO driver is named SQLite.

For a SQLite2 database:

new SQLite2("database");
Tom Haigh
+2  A: 

Try:

apt-get install php5-sqlite

in addition to:

apt-get install php5-sqlite3

That worked for me.

Stacey Richards
+1  A: 

The accepted answer is not complete without the remainder of instructions (paraphrased below) from the forum thread linked to:

cd /etc/php5/conf.d

cat > sqlite3.ini
# configuration for php SQLite3 module
extension=sqlite3.so
^D

sudo /etc/init.d/apache2 restart
btk