[Lighttpd] Writing to an external file?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

    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:

        $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>";

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

        $dbh = null;

Re: Writing to an external file?

Quoted text here. Click to load it

This is normal.  HTTP servers usually run with very restrictive
Giving an HTTP server write access to /var is asking for trouble...

Perhaps you should rethink what your problem really is.  I am guessing
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
by Lighttpd or deny HTTP access to the file or its containing
directory using
the url.access-deny directive available in Lighttpd:



Site Timeline