Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 24th, 2008, 12:35 PM
Gilles Ganault
Guest
 
Posts: n/a
Default [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;
  #2  
Old March 24th, 2008, 08:55 PM
NC
Guest
 
Posts: n/a
Default Re: Writing to an external file?

On Mar 24, 4:32 am, Gilles Ganault <nos...@nospam.comwrote:
Quote:
>
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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles