[英]PHP + SQLite3 on Amazon AMI (EC2)
我對此有一個類似的問題,我想在我的EC2(標准Amazon AMI)上支持sqlite3 php,但是PHP是使用--without-sqlite3
編譯的。
如何添加sqlite3支持? 它的軟件來自存儲庫,所以我不能只重新運行./configure
腳本
更多信息:
我嘗試從PECL安裝它並沒有獲得很大的成功,而且它說版本是0.6 (alpha)
,而sqlite3支持只能通過PECL短暫獲得,應該編譯為PHP可執行文件(我認為)。 令人困惑。
我也有PDO擴展名(某些網站說sqlite3在PDO中)
這是我嘗試過的PECL:
ec2-user[~]> pecl search sqlite
Retrieving data...0%
..Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest) Local
PDO_SQLITE 1.0.1 (stable) SQLite v3 Interface driver for PDO
SQLite 1.0.3 (stable) SQLite database bindings
sqlite3 0.6 (alpha) SQLite v3 Database Bindings.
ec2-user[~]> pecl download sqlite3
Failed to download pecl/sqlite3 within preferred state "stable", latest release is version 0.6, stability "alpha", use "channel://pecl.php.net/sqlite3-0.6" to install
download failed
ec2-user[~]> pecl download channel://pecl.php.net/sqlite3-0.6
downloading sqlite3-0.6.tgz ...
Starting to download sqlite3-0.6.tgz (768,302 bytes)
.........................................................................................................................................................done: 768,302 bytes
File /home/ec2-user/sqlite3-0.6.tgz downloaded
ec2-user[~]> sudo pecl install sqlite3-0.6.tgz
84 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Optionally provide the path to the libsqlite3 library [autodetect] : yes
building in /var/tmp/pear-build-root8Jljf1/sqlite3-0.6
(...)
/var/tmp/sqlite3/sqlite3.c:1586: error: duplicate 'static' // repeated lots of times
make: *** [sqlite3.lo] Error 1
ERROR: `make' failed
編輯:沒有php-sqlite
或php5-sqlite
包
ec2-user[~]> sudo yum search sqlite
Loaded plugins: fastestmirror, priorities, security, update-motd, upgrade-helper
Loading mirror speeds from cached hostfile
* amzn-main: packages.us-west-2.amazonaws.com
* amzn-updates: packages.us-west-2.amazonaws.com
========================================================================= N/S Matched: sqlite ==========================================================================
apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver
libdbi-dbd-sqlite.x86_64 : SQLite plugin for libdbi
python-sqlite.x86_64 : Python bindings for sqlite.
python24-sqlite.x86_64 : Python bindings for sqlite.
sqlite-devel.x86_64 : Development tools for the sqlite3 embeddable SQL database engine
sqlite-doc.x86_64 : Documentation for sqlite
sqlite-tcl.x86_64 : Tcl module for the sqlite3 embeddable SQL database engine
perl-DBD-SQLite.x86_64 : Self Contained RDBMS in a DBI Driver
sqlite.i686 : Library that implements an embeddable SQL database engine
sqlite.x86_64 : Library that implements an embeddable SQL database engine
編輯2:啟用(默認情況下) 企業Linux附加軟件包(EPEL)存儲庫后,上述軟件包均不可用
我認為Amazon AMI現在可以解決此問題。 我從存儲庫安裝的默認PHP 5.4已啟用SQLite3支持。
[root@amazon-ami php.d]# php -m | grep sqlite
pdo_sqlite
sqlite3
[root@amazon-ami php.d]#
例如下面的代碼對我來說很好用:
$db = new SQLite3('localDB.sqlite');
$db->exec('CREATE TABLE test (foo STRING)');
$db->exec("INSERT INTO test (foo) VALUES ('bar')");
$results = $db->query('SELECT foo FROM test');
while ($row = $results->fetchArray())
echo $row['foo'];
我最終放棄了EC2,並選擇了在VM中使用Linux Mint。
如果有人知道解決方案,盡管我很樂意接受他的回答。
對於Amazon Linux上的sqlite,我執行了以下操作:
sudo yum install sqlite-devel
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.