问题描述
WHM 64升级后,无法访问eximstat数据库. MySQL代码已更改为PDO以访问sqlite3 db,如下所示:
After WHM 64 upgradation, cant access eximstat db. MySQL code changed to PDO for accessing sqlite3 db as follows:
$db = new PDO('sqlite:/var/cpanel/eximstats_db.sqlite3', DB_USER, DB_PASSWORD);
故障,延迟表都为空白.实际上,是在var/cpanel目录中创建了一个新的空白文件,而不是连接到eximstats db.出乎意料的是,CPanel:查看已发送的摘要"可以正确提取所有信息,但是我无法访问驻留在域中的脚本.
The failues, defers tables are all blank. In fact, a new blank file was getting created in the var/cpanel directory, instead of getting connection to eximstats db. Surprisingly, CPanel:'View Sent summary' fetch information all correctly, But I cant access in my script which is residing on the domain.
非常感谢您的帮助.
谢谢!
推荐答案
在cPanel的出色支持下的聊天过程中,我们发现了这一点:
During a chat with the excellent support of cPanel, we figured out this:
eximstats_db.sqlite3表的权限存在问题:您试图以非root用户身份访问数据库,但是数据库由root拥有,并且只能由root写入.
It is a problem with rights for eximstats_db.sqlite3 table: you are trying to access the database as a non-root user, but database is owned by root and only writable by root.
理论上,您应该能够通过将SQLITE3_OPEN_READONLY标志传递给打开文件的调用来直接访问文件,如下所示:
In theory you should be able to access the file directly by passing the SQLITE3_OPEN_READONLY flag to the call to open the file as outlined here:
https://secure.php.net/manual/en/sqlite3 .open.php
因此授予对eximstats_db.sqlite3表的读取访问权限(注意!其中有3个):
So granting read access to eximstats_db.sqlite3 tables (NB! there are 3 of them):
-rw----r-- 1 root root 135168 Jun 10 06:06 eximstats_db.sqlite3
-rw----r-- 1 root root 32768 Jun 12 14:34 eximstats_db.sqlite3-shm
-rw----r-- 1 root root 1058512 Jun 12 14:34 eximstats_db.sqlite3-wal
并使用
$dbh = new SQLite3('/var/cpanel/eximstats_db.sqlite3',SQLITE3_OPEN_READONLY);
应该可以,但不能.这似乎是PHP中SQlite3库的限制:即使对于只读访问,它也希望锁定对文件的访问.因此,您还需要授予他们写访问权限:
should work, but it doesn't. It appears to be a limitation with the SQlite3 library within PHP: even for read-only access it wants to lock access to the file. So you need to give them also write access:
-rw----rw- 1 root root 135168 Jun 10 06:06 eximstats_db.sqlite3
-rw----rw- 1 root root 32768 Jun 12 14:34 eximstats_db.sqlite3-shm
-rw----rw- 1 root root 1058512 Jun 12 14:34 eximstats_db.sqlite3-wal
就是这样.之后,您将看到延期,失败和其他表格.
That's that. After that, you'll see the defers, failures and other tables.
(当然,在现实生活中,您可能希望创建一个组,并仅授予该组而不是所有人以读写权限).
(Of course, in real life you might want to create a group and give read-write access to that group only, not everybody).
如果您无法更改对这些数据库文件的权限,那么我看到的唯一解决方案是将文件复制到域,在此处更改权限,然后改为使用这些文件:
If you are not able to change permissions to these database files then the only solution I can see is to copy the files to domain, change the permissions there and then use these files instead:
$target = '/var/cpanel/eximstats_db.sqlite3-shm';
$newfile = '/home/yourdomain/where/your/script/is/eximstats_db.sqlite3';
copy($target, $newfile);
chmod($newfile, 0777);
// same with all 3 files..
$dbh = new SQLite3('eximstats_db.sqlite3'); // not '/var/cpanel/eximstats_db.sqlite3'!
这篇关于WHM64升级后无法访问eximstats sqlite3 db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!