Hi all,
I’m trying to get Apache and PHP working and coming up against a wall of bewilderment re file permissions.
I’ve run ls -l against all folders above htdocs and get this (after messing with permissions back to srv) srv folder:
dr-xr-x— 4 wwwrun www 4096 Mar 2 2011 srv www folder:
dr-xr-x—+ 6 wwwrun www 4096 Oct 9 12:41 www htdocs folder:
dr-xr-x—+ 10 wwwrun www 4096 Oct 27 21:30 htdocs my php test file:
-rwxr-xr-x+ 1 root www 78 Oct 27 21:30 info.php
So my test file is owned by root and is readable and x-able by the www group. (I’ve checked that wwwrun is indeed a member of www.
**
Problem is this:**
The only way I can get the file to execute is to set wwwrun as the owner of the file. Am I missing something here? Or is this what everyone does?
Here’s the situation on my systems:
htdocs is 755 root root, ditto for srv and www
In htdocs I have folders for multiple websites, for example “openSUSE”
openSUSE is 755 wwwrun www
In the “openSUSE” all is owned by wwwrun, group www, perms of the *.php files is 644, some exceptions 444. So, none executable. That may also be the point; I can change the ownership of the entire example site to my own user and group and it still runs. If I put a simple info.php and go to 127.0.0.1/openSUSE/info.php it opens fine in a browser.
Thank you. That makes sense as far as security is concerned. I’m still not sure why we need to set Apache as the owner. Logically the files could be owned by anyone, with the group www being given read and execute permissions as necessary? But yeh, my grubby little test file executes under that set-up. Thanks again.
First of all the Unix executable bit is not relevant to PHP or any other scripting language that is not running as an external CGI. These are scripts that only need to be read by the PHP interpreter, not executed in the Unix sense as a native binary.
You should always look at the log files (/var/log/apache2/error_log and /var/log/apache2/access_log) for any additional information. No need to go guessing when you can collect more clues.