简体   繁体   English

SQLite PHP权限问题/写入其他文件夹

[英]Sqlite PHP permission issue / writing to a different folder

I have two sites running off a single box that answers on different ip addresses. 我有两个站点运行在一个可以在不同IP地址上回答的盒子上。

Both of these sites have different root folders /var/www/ and /var/www2 . 这两个站点都有不同的根文件夹/var/www//var/www2

/var/www contains the main site and a sqlite database. /var/www包含主站点和一个sqlite数据库。

/var/www2 contains a few scripts that need to access that same db. /var/www2包含一些需要访问同一数据库的脚本。

I have tried 我努力了

    $db = new PDO('sqlite:/var/www/db.sqlite');

from the second site, but, I keep getting File not found , and in the logs I get 从第二个站点,但是,我不断得到File not found ,并在日志中得到

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,``

Both of these sites work fine when reading/writing to dbs in their own folder without the path. 当在没有路径的情况下读取/写入自己文件夹中的数据库时,这两个站点都可以正常工作。

Can anyone advise anything? 有人可以建议什么吗?

Well it is permission problem. 那么这是权限问题。 Site1 http server runs under site1 user and site2 under site2 user . Site1 http服务器在site1用户下运行,site2在site2用户运行

Possible solutions are: 可能的解决方案是:

  1. Set 0666 (writable from everyone) permission to /var/www/db.sqlite which is pretty not secure 设置对/var/www/db.sqlite的0666(可从所有人写入)权限,这不太安全
  2. Set 0660 (owner + group writable) to sqlite, add both site users to same group and chgrp of db.sqlite to your created group . 将0660(所有者+组可写)设置为sqlite,将两个站点用户都添加到同一组中,并将db.sqlite的chgrp添加到您创建的组中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM