Webserver permissions and PHP
Posted by JimL (JimL), 15 November 2004A bit of an obscure question:
On our webserver I have noticed that for PHP files to execute, the folder they are in must have executable rights. However, the PHP files themselves don't (they generally only have 664 (rw-rw-r--) permissions).
I find this a little confusing. Surely the PHP file should itself be executable?
Can anyone explain, or does anyone know any links to relevant information?
Posted by John_Moylan (jfp), 15 November 2004Now I may be talking complete drivel here, but heres my potentially wrong take on it.
You PHP page/script work when not executable because the webserver reads it, and then parses/executes what it reads and spits out the output of the script to the browser.
A directory must always be executable, otherwise you could not open it, thats why your scripts stop working when the 'x' bit is not turned on i.e. the webserver cannot open the directory.
If you run PHP on the command line and not the webserver thats a different beast. You will need to have the x bit turned on if you invoke your script by name.
for example if the permissions on script .php were
on the command line you cannot just type:
and expect it to run. You could tell PHP on the command line to run it though with these permissions with:
If the permissions were
then you could just type
and you have php in your $PATH (thats another paragraph though and may not be of interest here)
hope this helps
Posted by JimL (JimL), 15 November 2004Thanks!
Yes, your reply does make a lot of sense! I didn't realise that the executable permission on the directory was necessary to open the directory!
Also it makes sense that the PHP module just reads the PHP file, and then 'does it's own thing', spouting out the required HTML itself. The PHP file isn't some sort of executable, it's just a set of instructions for the PHP module to read.
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho