Steve V.
Steve V.

Reputation: 453

Minimum permissions needed to allow PHP PDO / Apache access to SQLite database in /var/www

SOLVED: See my answer below

I'm experiencing the same issue that Austin Hyde experienced in this question. I have an SQLite database that I can read, but not write.

Specifically, I'm getting General error: 8 attempt to write a readonly database in /var/www/html/green/database.php on line 34

My issue diverges from his as follows:

-As recommended in the answers to his question, I've made the database world-writeable, as well as the folder in which the database resides, with no luck. I've also set the owner of the database to "apache" as well as "nobody", without success.

-I've set the entire path set 777, beginning at /var (which I hate to do), no joy.

-I've messed about with SELinux (I'm running Fedora 12) to let httpd do whatever it wants; nothing.

I feel that I'm almost certainly missing something simple here, but I'm out of ideas.

What permissions need to be on an SQLite file in order to allow PHP / Apache to read and write to it via PDO?

Edit: Another related question, adding weight to the hypothesis that I've got a write permissions conflict somewhere.

Upvotes: 3

Views: 2719

Answers (1)

pbera
pbera

Reputation: 46

For those who can not afford to disable SELinux entirely, here is the way to go.

To make a directory (say rw_data) and all it's content writable to any process running in httpd_t domain type ie. web-server processes, use following command as root.

chcon -R -t httpd_sys_content_rw_t "/var/www/html/mysite/rw_data/"

you can check SELinux context labels with following command :

ls -Z /var/www/html/mysite | grep httpd_sys_content_rw_t

This works on Fedora 16, should work on other SELinux enabled distros too.

Upvotes: 3

Related Questions