LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PHP script permission problem (https://www.linuxquestions.org/questions/linux-newbie-8/php-script-permission-problem-401624/)

deadlock 01-10-2006 09:47 AM

PHP script permission problem
 
I am trying to teach myself how to use php as part of learning to better administer our new wiki server.

I am trying to follow the tutorial in O'Reilly's "PHP and MySQL" manual and am having some weird results.

I have written a (very) simple "Hello World" script from the manual. Placing it in a directory off the main web-server root (phptest/) I initially got some permission errors. I tried changing the permissions from default and changing the owner to root. Still no joy.

Doing some digging I found another site which suggest running a simple phpinfo() script to test the php install. This ran with no problems in the same location and with the same owner/permission as the original.

I then compared my handwritten script with the example script downloaded from the support site for the manual. The downloaded script works.

At this point I diff the scripts. No difference other than a few line breaks and white space. I have now corrected my script so that all the tabs are converted to spaces and line breaks are identical. Diff confirms no difference.

My script still doesn't run.

Finally I rename my script to something else. I make a copy of the example script to the same name as my script. It still works. Changing back to my script I still get the same error message...

Any Help?

Dtsazza 01-10-2006 11:22 AM

That sounds bizarre... at a guess, it could be something to do with the character encoding used. I suppose it's possible that you've somehow used a weird encoding that PHP doesn't like, but that diff can deal with and automatically converts when diffing the scripts... I find it highly unlikely that diff would be more tolerant of differences that the PHP interpreter, though. Something to chew on.

Out of interest, what editor did you use to create the file? And do you get any error messages when your script fails, or does it just do nothing?

deadlock 01-10-2006 11:28 AM

The error given is as follows:

"Forbidden
You don't have permission to access /phptest/hello.php
Additionally, a 403 Forbidden error was encountered while trying to use and ErrorDocument to handle the request."

Dtsazza 01-10-2006 11:34 AM

In which case, can you ls -l the directory where the scripts live? It looks like it's still a permissions issue, and would also explain why copying the working file still works.

deadlock 01-11-2006 04:20 AM

The folder is as follows:

Code:

total 32
-rw-r--r--  1 root root 356 Jan 10 15:20 example.php
-rw-r--r--  1 dan  dan  410 Jan 10 17:20 hello2.php
-rw-r--r--  1 root root 355 Jan 10 15:31 hello.php
-rw-r--r--  1 root root  17 Jan 10 14:59 phpinfo.php

The ones we are interested in are example.php and hello.php - example works, hello doesn't.

hello2.php is a copy of example I have been using to continue the tutorial and is working fine. Phpinfo.php is a very simple php script that also works.

Dtsazza 01-11-2006 04:53 AM

That is indeed quite bizarre that example.php works and hello.php doesn't, with the permissions set as they are, since a)they both have the same permissions, and b)neither is executable...

It's generally accepted practice that website scripts should be chmodded 755 (i.e. -rwxr-xr-x), which should allow everyone (world) to execute them (a good thing for a wewbsite!), and doesn't pose any security risks. If you set up your scripts like this, you should (touch wood) be fine.

HTH,
Andrzej

deadlock 01-11-2006 05:33 AM

I've changed the permissions to 755 and am still getting the same error on the hello script.

It's reached the point that I don't need to fix this in order to get on with things, but would like to know whats going on...

muha 01-11-2006 05:56 AM

hmm, maybe post example.php and hello.php here so we can have a try a running those on our servers to see that it works here :) ?

Dtsazza 01-11-2006 06:34 AM

Hmm, I'm afraid I'm out of ideas, though I'll keep watching this thread (both out of curiousity, and if something more concrete comes to light). I've got a feeling it's one of those things where you're not doing quite what you think, and it's really obvious when you notice it.

Something like a typo in the html source, or somehow having two copies of the directory, one of which you're changing and the other of which is being read. Something like that, anyhow.

Good luck uncovering what it is - I know you can carry on anyway, but these little things are a little annoying, and besides, who's to say it won't happen again in future until you know what it is? :)


All times are GMT -5. The time now is 07:18 AM.