无法包含现有文件 - 无法打开流:权限被拒绝

this is not a duplicate question, I read all related questions, and didn't find my answer.

I want to include a file that exists :

/var/www/html/monitor/protected/extensions/curl/curl.php

and my code is :

include('/monitor/protected/extensions/curl/curl.php');

and I'm getting this error :

include(/var/www/html/monitor/protected/extensions/curl/curl.php): failed to open stream: Permission denied

and the file has 777 permission.

My question is :

is it possible that a file exists and have a 777 permission and a proper chown AND still give this error?

Update : I had used all three possible ways :

  1. include('/monitor/protected/extensions/curl/curl.php');

  2. include('monitor/protected/extensions/curl/curl.php');

  3. include('/var/www/html/monitor/protected/extensions/curl/curl.php');

Im using php 5.3

Note: when including another file in the same directory, it includes without any problem

You're using the wrong path. If the file exists at

/var/www/html/monitor/protected/extensions/curl/curl.php

Then you should include that exact string.

include('/var/www/html/monitor/protected/extensions/curl/curl.php');

/ means the root of the file system. You get permission denied because you most certainly don't have permission to / and /monitor doesn't exist

Alternatively you can include it relatively. By dropping the first / you would do:

include('monitor/protected/extensions/curl/curl.php');

This will work if the running script is also in /var/www/html.

I think you're getting confused at the difference between the HTTP path and the system path. PHP files are included from the system path and should be referenced by the system path.

I deleted the file, and created again, and my problem solved.

the original file was downloaded from the internet and unzipped from a zipped file.

I think there was a problem with creating the file by original author.

This is very odd! but it worked

I know this is late, but I just want to confirm Alireza Fallah's answer. This also worked for me. It looks like it has to be the original owner. So unzip/unrar the php files on the same machine you want to use it on. Hope this helps!