LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Permission Denied PHP web pages (https://www.linuxquestions.org/questions/linux-newbie-8/permission-denied-php-web-pages-770628/)

Woogieman 11-21-2009 09:25 AM

Permission Denied PHP web pages
 
I copied an existing web site from a CentOS 5.4 box to another CentOS 5.4 box to the /var/www/html directory. I only have 1 web site on this box.
I changed the owners of all files to Group Apache and User ftpman.
FTP works fine and lets me login, copy and delete files.
VNC also works fine.

I can load part of the index.php file when load the site but the include files located in other directories give Apache "permission denied" error

I am stuck!!! Help!!!
I made sure all php files have permissions of -rwxr-xr-x or 0755 in all of the sub-directories also.

Any help will be greatly appreciated.

prik420 11-21-2009 10:07 AM

check the apache logs

what's the url where you're getting the error?

Web31337 11-21-2009 10:13 AM

no need to set 0755 perms on files, 0755 is for directories. 0644 is for files.
and apache won't give permission denied, it's PHP who gives it.
what is the absolute path of file you are trying to include()? what is the user webserver is working under? can you su to webserver's user and read that file? double-check permissions and owners.

Woogieman 11-21-2009 11:33 AM

Permission Denied PHP web pages
 
Quote:

Originally Posted by prik420 (Post 3764978)
check the apache logs

what's the url where you're getting the error?

This is from my error.log file from Apache.
PHP Warning: include(atomix/support/HitCounter.php) [<a href='function.include'>function.include</a>]: failed to open stream: Permission denied in /var/www/html/index.php on line 191

The PHP code at line 191 is simply
Code:

include("atomix/support/HitCounter.php");
The permissions on the directory /atomix/ are drwxr-xr-x
The permissions on the directory /atomix/support/ are also the same
The permissions on the file HitCounter.php is -rwxr-xr-x as are all the PHP files on the entire site.

See my Quagmire??? :banghead: :scratch:

Woogieman 11-21-2009 11:38 AM

Permission Denied PHP web pages
 
Quote:

Originally Posted by Web31337 (Post 3764984)
no need to set 0755 perms on files, 0755 is for directories. 0644 is for files.
and apache won't give permission denied, it's PHP who gives it.
what is the absolute path of file you are trying to include()? what is the user webserver is working under? can you su to webserver's user and read that file? double-check permissions and owners.

Thanks for the tip on the files thing.
I am logged in and running the web server as root.
Refer to the preceding response from me on the file particulars.
Greatly appreciate all your help.

Web31337 11-21-2009 09:03 PM

how's that:
Quote:

I am logged in and running the web server as root.
you mean you start webserver under root and then it runs under something like www-data (unprivileged user) or you run it all under root? then i don't understand why "permission denied".

my last guess: include_path in php.ini doesn't contain . at the first place?
try include("./atomix/support/HitCounter.php");
--
upd: check echo ini_get('include_path');

Woogieman 11-22-2009 08:25 AM

Permission Denied PHP web pages
 
Quote:

Originally Posted by Web31337 (Post 3765334)
how's that:
you mean you start webserver under root and then it runs under something like www-data (unprivileged user) or you run it all under root? then i don't understand why "permission denied".

my last guess: include_path in php.ini doesn't contain . at the first place?
try include("./atomix/support/HitCounter.php");
--
upd: check echo ini_get('include_path');

Yea I'm a newbie and self taught with a background in Novell and Windows Networks. I know just enough to be dangerous. I run the whole shebang logged in as 'root'. I have not been able to figure out how to create a super-user to replace root.
I hope I got this right. my include_path var was commented out and read:
;include_path = ".:/php/includes"
Which I changed to:
include_path = "."
Is this correct? Or do I need to add a directory name after the .
If so what is the separator between directories?
Once again thanks a lot for your time!!

Web31337 11-22-2009 09:31 AM

does it work now? i have no idea how that can result in "permission denied" under root o_0
basically it's a good practice to establish the full path of your application's includes directory on the target system and then work with it.
just in addition you may change include_path to ".:/var/www/html"

Woogieman 11-23-2009 08:48 AM

Quote:

Originally Posted by Web31337 (Post 3765758)
does it work now? i have no idea how that can result in "permission denied" under root o_0
basically it's a good practice to establish the full path of your application's includes directory on the target system and then work with it.
just in addition you may change include_path to ".:/var/www/html"

Thanks for the tip on the path I will do that today;
It works now but what I did is change the Owner and Group for the site. I changed the owner to Apache and the Group to ftp-users. Everything works now except my FTP won't let me overwrite files. I am slowly getting it and only have to finish the FTP and I am cooking.
I really appreciate your help. Too much information fills up the memory banks and I need to flush every once in a while.
Thanks again.

prik420 11-23-2009 11:53 PM

for ftp, try this workaround:

add your user to the ftp-users group then add write permissions for this group to the /var/www/html folder, recurse if needed.

i hope this helps.

Woogieman 11-25-2009 09:10 AM

Permission Denied PHP web pages
 
Quote:

Originally Posted by prik420 (Post 3767556)
for ftp, try this workaround:

add your user to the ftp-users group then add write permissions for this group to the /var/www/html folder, recurse if needed.

i hope this helps.

Thanks for the tip. That is exactly what I did. Except I made my 1 FTP user the owner of the directory(s) and apache is the main group. After doing that on all files I now know what the process is.
I really appreciate your help and I have solved the problem with the help of everyone here.
Thanks again!!!


All times are GMT -5. The time now is 08:14 AM.