0
我在,我连一个SQLite数据库这个简单的PHP代码...错误时访问SQLite数据库从PHP(但它的命令行的作品...)
<?php
ini_set('display_errors', 1);
echo 'Current script owner: ' . get_current_user();
# Set access to data base...
$db = new SQLite3('/var/www/html/OpenProntoSoccorso/Test/OpenProntoSoccorso.sqlite');
echo ".... Connessione db OK! ...";
?>
当我尝试从浏览器我有这个错误执行...
Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in /var/www/html/OpenProntoSoccorso/Test/testSpatialite.php:6 Stack trace: #0 /var/www/html/OpenProntoSoccorso/Test/testSpatialite.php(6): SQLite3->__construct('/var/www/html/O...') #1 {main} thrown in /var/www/html/OpenProntoSoccorso/Test/testSpatialite.php on line 6
但是当我尝试执行形式的命令行所有做工精细
[email protected]:/var/www/html/OpenProntoSoccorso/Test# ls -l
total 336536
-rwxr-x--- 1 root root 330037248 Aug 17 14:20 OpenProntoSoccorso.sqlite
-rw-rw-r-- 1 osboxes osboxes 133 Aug 17 13:51 testSpatialite.php
[email protected]:/var/www/html/OpenProntoSoccorso/Test# php testSpatialite.php
.... Connessione db OK! [email protected]:/var/www/html/OpenProntoSoccorso/Test#
我已经试图改变业主和/或集团,但没有任何变化...
建议?
预先感谢您!
您的权限错误。现在只有root可以访问该数据库。您的PHP不会(也不应该)以您的Web服务器上的根用户身份运行。但是当你从命令行登录时,你以root登录,因此当你执行PHP代码时,它具有root权限 – litelite
如果我尝试将OpenProntoSoccorso.sqlite所有者和组更改为“osboxes”,我的行为是一样的。 ... – Cesare
很可能是因为您的网络服务器不能像osboxes那样运行,而是像其他一些不受约束的用户那样运行 – litelite