how to enable sqlite3 for php?

2019-01-06 09:45发布

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");

标签: php sqlite3
10条回答
Lonely孤独者°
2楼-- · 2019-01-06 10:00
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

That worked for me.

查看更多
唯我独甜
3楼-- · 2019-01-06 10:01

Try:

apt-get install php5-sqlite

That worked for me.

查看更多
家丑人穷心不美
4楼-- · 2019-01-06 10:09

Edit: This answer is outdated, but can't be removed because it's accepted. Please see the solution from Stacey Richards for the correct answer.

 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.

查看更多
贼婆χ
5楼-- · 2019-01-06 10:14

In Centos 6.7, in my case the library file /usr/lib64/php/modules/sqlite3.so was missing.

yum install php-pdo 

vim /etc/php.d/sqlite3.ini
; Enable sqlite3 extension module
extension=sqlite3.so

sudo service httpd restart
查看更多
登录 后发表回答