php 如何为php启用sqlite3?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/948899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to enable sqlite3 for php?
提问by Moon
I am trying to install sqlite3 for PHP in Ubuntu.
我正在尝试在 Ubuntu 中为 PHP 安装 sqlite3。
I install apt-get php5-sqlite3and edited php.inito include sqlite3 extension.
我安装apt-get php5-sqlite3并编辑php.ini为包含 sqlite3 扩展。
When I run phpinfo();I get
当我跑步时,phpinfo();我得到
SQLITE3
SQLite3 support enabled
sqlite3 library version 3.4.2
as shown above, sqlite3is enabled. However, I get "Class SQLite3 not found" when I use
如上所示,sqlite3已启用。但是,当我使用时,我得到“Class SQLite3 not found”
new SQLite3("database");
采纳答案by miccet
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.
编辑:此答案已过时,但无法删除,因为它已被接受。请参阅 Stacey Richards 的解决方案以获取正确答案。
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.
从ubuntu 形式撕下来。
回答by Stacey Richards
Try:
尝试:
apt-get install php5-sqlite
That worked for me.
那对我有用。
回答by theczechsensation
For PHP7, use
对于 PHP7,使用
sudo apt-get install php7.0-sqlite3
and restart Apache
并重新启动Apache
sudo apache2ctl restart
回答by btk
The accepted answer is not complete without the remainder of instructions (paraphrased below) from the forum threadlinked to:
如果没有来自链接到的论坛线程的其余说明(如下释义),则接受的答案是不完整的:
cd /etc/php5/conf.d
cat > sqlite3.ini
# configuration for php SQLite3 module
extension=sqlite3.so
^D
sudo /etc/init.d/apache2 restart
回答by Jarek Jakubowski
For Ubuntu 18.04 and PHP 7.2:
对于 Ubuntu 18.04 和 PHP 7.2:
sudo apt install php-sqlite3
sudo apt install php-sqlite3
回答by Tom Haigh
The SQLite3 PDO driver is named SQLite, not SQLite3, so you can do:
SQLite3 PDO 驱动程序名为 SQLite,而不是 SQLite3,因此您可以执行以下操作:
new SQLite("database");
For a SQLite2 database:
对于 SQLite2 数据库:
new SQLite2("database");
回答by sanjeev
one thing I want to add , before you try to install
在您尝试安装之前,我想添加一件事
apt-get install php5-sqlite
or
或者
apt-get install php5-sqlite3
search the given package is available or not :-
搜索给定的包是否可用:-
# apt-cache search 'php5'
After that you get :-
之后你得到:-
php5-rrd - rrd module for PHP 5
php5-sasl - Cyrus SASL extension for PHP 5
php5-snmp - SNMP module for php5
**php5-sqlite - SQLite module for php5**
php5-svn - PHP Bindings for the Subversion Revision control system
php5-sybase - Sybase / MS SQL Server module for php5
Here you get an idea about whether your version support or not .. in my system I get php5-sqlite - SQLite module for php5so I prefer to install
在这里,您可以了解您的版本是否支持 .. 在我的系统中,我得到了php5-sqlite - php5 的 SQLite 模块,所以我更喜欢安装
**apt-get install php5-sqlite**
回答by Bitcoin Mining
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.
那对我有用。
回答by Hazem Hagrass
try this:
尝试这个:
sudo 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
sudo apt-get install php5-sqlite
sudo apt-get install libapache2-mod-fastcgi php5-fpm php5
回答by satishwin
In Centos 6.7, in my case the library file /usr/lib64/php/modules/sqlite3.so was missing.
在 Centos 6.7 中,就我而言,缺少库文件 /usr/lib64/php/modules/sqlite3.so。
yum install php-pdo
vim /etc/php.d/sqlite3.ini
; Enable sqlite3 extension module
extension=sqlite3.so
sudo service httpd restart

