views:

95

answers:

3
<?PHP

print "hello";

?>

I write this code and save as "1.php";

Then I upload this PHP script to my server.

I have 8 diffrent free hosting server's accounts.

And I noticed that there are 2 types of server settings.

(1)
"type A"
for exapmle, sqweebs.

We need to set the PHP file permission as 640.
This means that sqweebs server requires us
to give group permission for PHP script running.

If I set 604,then the server generate such a errors.like,

Warning: Unknown: 
failed to open stream:
 Permission denied in Unknown on line 0

Fatal error: Unknown: 
Failed opening required 
'/www/sqweebs.com/1.php' 
(include_path='.:/blahblah') 
in Unknown on line 0


(2)
On the other hand ,there are other type
servers on this world.

"Type B",
for example, izfree.

On this server, I found that
I can make PHP script work if I give it
604 as the permission.


So I want to know why there are many server settings,
and what is the reason, and some other related
opinions.

like which server should I use ,or etc,etc.

A: 

It probably depends on the permissions and under which group/user the apache is running. If it's running with your rights, you will be fine with 600, if the apache is not even in the same group as you are you probably need something like 604. All I'm saying is, it depends on the server configuration AND the file permissions. This is a wild guess, but if you really need something like 604, it could be a sign that there is potentially something wrong and other users maybe able to look into your home directory...

merkuro
Which book, or web site should I read? to learn and study about this kind of issues? I have read 15 PHP book, but can not stillget the glance.
aaa
+1  A: 

The problem is probably with using the free hosts. They add server limitations, and most likely, disable/enable certain restrictions that they feel are fit for administering how you can behave on their site.

Ian Elliott
Do you know any good free servers?
aaa
A: 

it is expected, by the webserver, that the file has to have the permission for the user that the webserver runs as, to open and run it.

So, if the webserver (say Apache) runs as www, then www should have read access to the file. (some run apache as www, and some run it as apache, or nobody).

When you upload the file, depending on how the umask is set, the file permission is set so. (so, on one host, the file could have permission 655 or other could be 600, when permission is not set explicitly).

It always helps if you know a bit about the OS you normally deploy your applications on. Mostly, PHP is deployed on *nix system, and permission scheme is nearly (almost always) same across all the *nix systems.

Try getting hold of "Unix system Administration Handbook" (by Evi Nemeth & Co). Its quite fun to read and easy to understand (it is an old edition .. but unix permissions have not changed)

Ram Prasad
Also, make sure your server can handle DOS end of line settings (are you developing code on windows ?). Make sure, when you save, you save it as "Unix format" EOL (end of line). (most editors like Dreamweaver provide the feature). Most of the hosting (PHP) providers run some form of *nix (freeBSD, Linux etc), and webservers on these cause issue with the Windows EOL format.
Ram Prasad
You mean BOM? .
aaa