469,609 Members | 1,713 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

[Lighttpd] Writing to an external file?

Hello

There's not much activity in the Lighttpd forum, so I figured maybe
some people here use this web server instead of Apache, and would know
the cause of the problem.

PHP scripts can successfully read/write to an SQLite file when it's
located either in Lighttpd's web directory (/usr/local/www/data/) or
in /tmp, but it fails writing when the file is located elsewhere (such
as /var).

I've checked file and directory ownership and access rights, as well
as /usr/local/etc/lighttpd.conf and Lighttpd's error log, to no avail.
I don't know where else to look for an explanation. Any idea?

Thank you.

PS : Here's the test code I use:

//BAD
$dbh = new PDO("sqlite:/var/test.sqlite");
//GOOD $dbh = new PDO("sqlite:test.sqlite");
//GOOD $dbh = new PDO("sqlite:/tmp/test.sqlite");

$time = time();
$current = date("Y-m-d H:i:s",$time);
$sql = "INSERT INTO mytable VALUES (NULL,'$current')";
print "$sql<hr>";
$dbh->exec($sql);

$sql = "SELECT * FROM mytable";
foreach($dbh->query($sql) as $row) {
print $row['name'] . "<p>\n";
}

$dbh = null;
Mar 24 '08 #1
1 2492
NC
On Mar 24, 4:32 am, Gilles Ganault <nos...@nospam.comwrote:
>
PHP scripts can successfully read/write to an SQLite file when it's
located either in Lighttpd's web directory (/usr/local/www/data/) or
in /tmp, but it fails writing when the file is located elsewhere (such
as /var).
This is normal. HTTP servers usually run with very restrictive
permissions.
Giving an HTTP server write access to /var is asking for trouble...

Perhaps you should rethink what your problem really is. I am guessing
that
you want to protect your SQLite data file from downloading via HTTP.
In that
case, you should either place it outside the Web root into a directory
owned
by Lighttpd or deny HTTP access to the file or its containing
directory using
the url.access-deny directive available in Lighttpd:

http://trac.lighttpd.net/trac/wiki/Docs%3AModAccess

Cheers,
NC
Mar 24 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.