OpenWrt Forum Archive

Topic: PHP5 + SQLite + other extensions

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hello there!

I am trying to get php5 running, to be exactly the extensions for sqlite, gd and mysql.

- I have told php to load these extensions in the php.ini
- I have a php script that is trying to load the sqlite.so via dl('sqlite')

In both cases I get the following error:

Warning: dl() [function.dl]: Unable to load dynamic library '/usr/lib/php/sqlite.so' - File not found in /www/testing.php on line 2

Needless to say that /usr/lib/php/sqlite.so' actually exists.

Versions in use are from http://downloads.openwrt.org/backports/0.9/

Hope anyone can help.



greetings, jack

- Which related php5 packages did you installed from 0.9 backports?
- Can you show us the code of your testing.php file?
- Are you using lighttpd webserver?

Try using

          dl("sqlite.so")

This works for me. You can test it with phpinfo() function to see if the sqlite library gets loaded at runtime.

(Last edited by forum2006 on 4 Mar 2007, 22:23)

thanks for your reply!

well, i have installed the following from the 0.9 backports
- php5-cgi_5.0.5-1_mipsel.ipk
- php5-mod-gd_5.0.5-1_mipsel.ipk
- php5-mod-mysql_5.0.5-1_mipsel.ipk
- php5-mod-sqlite_5.0.5-1_mipsel.ipk

and I run lighttpd_1.4.11-2 with lighttpd-mod-cgi_1.4.11-2 (from the packages for 0.9).

and the testing.php is just a sample snipped from the php.net online reference:

<?php
dl('sqlite.so');

if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
  sqlite_query('CREATE TABLE foo (bar varchar(10))');
  sqlite_query("INSERT INTO foo VALUES ('fnord')");
  $result = sqlite_query('select bar from foo');
  var_dump(sqlite_fetch_array($result));
} else {
  die ($sqliteerror);
}
?>

When I call the php script I also get the following on the command line:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/mysql.so' - File not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/sqlite.so' - File not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/gd.so' - File not found in Unknown on line 0

As I wrote before, loading of these extensions is also definded in the php.ini:

extension_dir = "/usr/lib/php"
extension=mysql.so
extension=sqlite.so
extension=gd.so

Basically I just need the sqlite extension. I've just installed the others to see if its a sqlite-only problem.

And: Do I need to install anything else for sqlite (from the php manual I would say no)?


update:
as others seem to have similar problems, can one try to recompile php5 and its extensions please? (if I knew how to write the Makefile I would have done it already)

(Last edited by thengineer on 4 Mar 2007, 22:28)

There you go:

<?php
dl("sqlite.so");

if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror)) {
  sqlite_query($db,'CREATE TABLE foo (bar varchar(10))');
  sqlite_query($db,"INSERT INTO foo VALUES ('fnord')");
  $result = sqlite_query($db,'select bar from foo');
  var_dump(sqlite_fetch_array($result));
} else {
  die ($sqliteerror);
}

?>

Gives me in the browser:

array(2) { [0]=> string(5) "fnord" ["bar"]=> string(5) "fnord" }

/etc/php.ini

[..]
;extension=sqlite.so
[..]

The related packages (and dependencies) which I have installed (from 0.9 backports) are:

php5 - 5.0.5-1 -
php5-cgi - 5.0.5-1 -
php5-mod-gd - 5.0.5-1 -
php5-mod-mysql - 5.0.5-1 -
php5-mod-sqlite - 5.0.5-1 -
lighttpd - 1.4.11-1 -
lighttpd-mod-cgi - 1.4.11-1 -

Let me know if you still have the problem. Then I'll try to recompile PHP5 for latest WR.

(Last edited by forum2006 on 26 Mar 2007, 09:44)

okay, I have updated the php.ini again, and downgraded lighttpd to meet your version.

result: it still does NOT work.

could you share your sqlite.so please?

shame on me!!

it seems I have forgotten to install the corresponding libs.

however when one of the extensions gets loaded, the http connection to the wrt times out.

the interesting thing is:
- the php5-mod-gd from macsat.com works fine
- the php5-mod-gd from backports causes an timeout too.


so macsat: could you please recompile the extensions for sqlite and mysql too?

thanks in advance!

I had a similar problem with php5-mod-mysql not working. I have found, that the binaries from this backports repository work! I just downloaded "php5-cgi_5.0.5-1_mipsel.ipk" and "php5-mod-mysql_5.0.5-1_mipsel.ipk", unpacked them and copied the binaries "php" and "mysql.so", respectively, to the places where they belong and now mysql in php seems to work.

Chances are good that also the other modules will work. (i haven't tried, though)

(Last edited by synthrax on 6 Mar 2007, 22:23)

The discussion might have continued from here.