PHP files that are intended to be run as part of a web application do not need to have the execute bit set chmod +x
, because when the server finds a PHP file it executes the PHP interpreter, which then needs to have read access to the PHP source.
So, as the CS50 documentation will tell you, PHP files should be set chmod 600
. Except that ever since version 59 of ide50
, PHP files now require group-level read access: chmod 640
. Note that world-level permissions are "0", or non-existent.
The exception to this rule is that when you intend to run a PHP file in a Terminal (generally, interactively at the command-line prompt) then you should set chmod 700
for that file, and also include a "shebang" line like:
#!/usr/bin/env php
at the beginning of the file.
Also, in Debian GNU/Linux (and Debian-derived distributions such as Ubuntu, which is what ide.cs50.io
uses), the Apache server runs as user and group www-data
.
Click here for further explanation.