I have seen several similar questions, but no answer worked in my situation, except that it probably has something to do with permissions.
A PHP script served by Apache tells me unable to open database file
.
When I print the path to that file, it returns a valid path, say DBPATH. The file does exist at that location; I gave it and its parent folder 777
rights; I gave them user:user
access, where user
is the sudoer that all script files belong to. I did the same to the whole htdocs/
folder, just in case.
When I print file_exists(DBPATH)
, it returns false. Is is most likely a matter of permissions, but I don't know what I should change for PHP to have access rights. I tried apache:apache
, too. I cannot su apache
(user not available).
My scripts are in htdocs/
. DBFILE is somewhere out of it (I tried /tmp/test
, all in 777
, but no luck either).
No safe_mode, PHP 5.4 freshly installed, CentOS7.
Please someone give me a clue at least to help debug it. Maybe such as: how can I check whether my file will be readable from apache/my php script, without running the script itself? How can I get the name of the user that is used to execute it?
cat DBPATH
? – Venettaveneziafile_exists
does not lie, somewhere something is not right. I guess yourDBPATH
is not correct. Note that if you are including your file somewhere the current directory is that of the root document where everything is included in. – Inseparablepwd -P
), and I can "ls <DBPATH>" and see it exists and has 777 rights. I can open it with sqlite3 from anywhere else. – Remarkable