Training, Open Source computer languages

This is page http://www.wellho.net/forum/Writing-PHP/Webserve ... d-PHP.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Webserver permissions and PHP

Posted by JimL (JimL), 15 November 2004
A 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?

Cheers,  Jim

Posted by John_Moylan (jfp), 15 November 2004
Now 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
-rw-r--r--
on the command line you cannot just type:
Code:
script.php

and expect it to run. You could tell PHP on the command line to run it though with these permissions with:
Code:
php script.php
Note I actually invoke php here.

If the permissions were
-rwxr-xr-x
then you could just type
Code:
script.php
and it will run as long as you have the path to php at the start of the script
Code:
!#/path/to/php

and you have php in your $PATH (thats another paragraph though and may not be of interest here)

hope this helps
jfp

Posted by JimL (JimL), 15 November 2004
Thanks!

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.

Cheers,  Jim



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho