Why are PHP file operations failing

mik3ca

Verified User
Joined
May 31, 2026
Messages
13
I ran a test.
I made a special ram folder for my website. I managed to update the document root indirectly in the apache config to reflect that.

Suppose my folder and file structure is this:

In /myweb/public is index.php, the public file.
In /myweb/include is test.txt, a testing text file.

For every file and folder (include /myweb itself), I used the exact same linux group and user names for the domain. For permissions, I used 755.

Index contains this:
Code:
<?php
echo file_get_contents("/myweb/include/test.txt");
?>

For good measure, I executed the script from the commandline (SSH) as follows:

Code:
cd /myweb/public
php index.php

And I got the expected results, the contents of test.txt.

However, if I run it from a remote web browser, I get nothing, and my error log claims that the file /myweb/include/test.txt does not exist even though it does.

I also ensured open_basedir is disabled and I'm using PHP 8.0.

How can I fix this? Any fast answer is appreciated.
 
None of those. I'm using Cent0S 9 steam as the OS. No jailing.

I read online that my document root should exactly match /myweb (and not a symbolic link to it).

So I tried to setup a subdomain with:

Code:
|*if SUB="sub.domain.com"|
|?SDOCROOT=/myweb|
|*endif|

But when I checked the config files after issuing a "da build rewrite_confs", The document root is "/myweb/sub" instead of "/myweb" despite me using SDOCROOT instead of DOCROOT.

But it got worse.
When I make the document root this way, I get an HTTP 403 error with this error:
Code:
[proxy_fcgi:error] ...AH01071: Got error 'Primary script unknown'

But the index PHP script will load if I set the document root to anything within the user folder (say /home/user/domains/sub.domain.com) and then bind it as follows:

Code:
cd /home/user/domains
mkdir sub.domain.com
mount --bind /myweb  sub.domain.com

However in all cases I have set the user and group name and permissions correctly to match the user.

So what else could I be doing wrong? I want to run my website off a ramdrive
 
Back
Top