允许 PHP PDO / Apache 访问 /var/www 中的 SQLite 数据库所需的最低权限
已解决:请参阅下面的答案,
我遇到了与 Austin Hyde 在 这个问题。我有一个可以读取但不能写入的 SQLite 数据库。
具体来说,我收到一般错误:8尝试在第34行在/var/www/html/green/database.php中写入只读数据库
我的问题与他的不同之处如下:
-按照建议在回答他的问题时,我已经将数据库以及数据库所在的文件夹设置为全局可写,但没有成功。我还将数据库的所有者设置为“apache”和“nobody”,但没有成功。
-我已经将整个路径设置为 777,从 /var 开始(我讨厌这样做),没有乐趣。
-我搞乱了 SELinux(我运行的是 Fedora 12),让 httpd 做它想做的事;没有什么。
我觉得我几乎肯定错过了一些简单的东西,但我没有想法。
SQLite 文件需要什么权限才能允许 PHP / Apache 通过 PDO 读取和写入它?
编辑:另一个 相关问题,增加了我有写入的假设的权重某处权限冲突。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于那些无法完全禁用
SELinux
的人来说,这是可行的方法。要使目录(例如
rw_data
)及其所有内容可写入httpd_t
域类型中运行的任何进程,即。 Web 服务器进程,以root
身份使用以下命令。您可以使用以下命令检查
SELinux
上下文标签:这适用于
Fedora 16
,应该适用于其他启用SELinux
的发行版
也是。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 inhttpd_t
domain type ie. web-server processes, use following command asroot
.you can check
SELinux
context labels with following command :This works on
Fedora 16
, should work on otherSELinux
enableddistros
too.