It appears a common PHP configuration option is to build a shared
library and add a extension reference to it within the php.ini file [1],
[2]. If this is the case, you should be able to build a shared library
for sqlcipher and point your configuration to that instead. Could you
give that a try, we'd love to know if that works for you? Thanks!
1. http://www.php.net/manual/en/sqlite.installation.php#100554
2.
http://serverfault.com/questions/32982/how-do-i-enable-sqlite-on-linux-apache-php
On 3/22/12 11:18 PM, chen li wrote:
> it is strange that no one answer my post...
>
> On 3锟斤拷18锟斤拷, 锟斤拷锟斤拷1时02锟斤拷, chen li <china.lic...@gmail.com> wrote:
>> hi, all.
>>
>> I want to connect PHP sqlite with SQLCipher.
>>
>> But it is hard to search related document, the only one i have is as
>> below:
>>
>> http://groups.google.com/group/sqlcipher/browse_thread/thread/6d77e4e...http://groups.google.com/group/sqlcipher/browse_thread/thread/f0282f9...
>>
>> but still for me, it is too hard to understand step by step.
>>
>> Could anyone provide a guidance or a getting-started document for
>> SQLCipher in PHP?
>>
>> Thanks very much!
--
Nick Parker
Below are the step I went through to get PHP to recognize a sqlcipher
extension library. You might want to cross reference your steps to see
where they may differ. To begin with, I did this on a Ubuntu 11.10 VM.
This assumes you have the appropriate toolchain to build sqlcipher from
source (i.e., git, GNU compiler chain, OpenSSL).
Install Apache and PHP:
sudo apt-get install apache2
sudo apt-get install php5
Restart Apache:
sudo /etc/init.d/apache2 restart
Install php dev package for the phpize tool:
sudo apt-get install php5-dev
Build SQLCipher - only for the sqlite3.c file:
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC"
LDFLAGS="-lcrypto"
make
Download/extract PHP source (http://php.net/downloads.php) - I grabbed
the php-5.4.0.tar.bz2
tar xvfj php-5.4.0.tar.bz2
Build PHP enabled SQLCipher library
cd php-5.4.0/ext/sqlite3
phpize
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC"
LDFLAGS="-lcrypto"
cp [path to sqlcipher root directory]/sqlite3.c libsqlite
sed -i 's|PHP_FE_END|{NULL,NULL,NULL}|' sqlite3.c
make
The above steps will generate a file called sqlite3.so in the modules
directory. You then need to create an .ini file for the extension to be
loaded. On my machine, the directory that PHP monitors for
configurations was /etc/php5/apache2/conf.d. I created a file that
contained the following:
extension=/full/path/to/new/sqlite3.so
You will then want to restart Apache, if you create a PHP file that
contains the following, you should see information listed about the
sqlite extension being loaded by PHP.
<?php phpinfo(); ?>
Let us know if you're able to successfully build and configure this. Thanks!
--
Nick Parker