LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2006, 10:47 AM   #1
deadlock
Member
 
Registered: Apr 2003
Distribution: Red Hat
Posts: 65

Rep: Reputation: 15
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?
 
Old 01-10-2006, 12:22 PM   #2
Dtsazza
Member
 
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 31
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?
 
Old 01-10-2006, 12:28 PM   #3
deadlock
Member
 
Registered: Apr 2003
Distribution: Red Hat
Posts: 65

Original Poster
Rep: Reputation: 15
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."
 
Old 01-10-2006, 12:34 PM   #4
Dtsazza
Member
 
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 31
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.
 
Old 01-11-2006, 05:20 AM   #5
deadlock
Member
 
Registered: Apr 2003
Distribution: Red Hat
Posts: 65

Original Poster
Rep: Reputation: 15
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.
 
Old 01-11-2006, 05:53 AM   #6
Dtsazza
Member
 
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 31
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
 
Old 01-11-2006, 06:33 AM   #7
deadlock
Member
 
Registered: Apr 2003
Distribution: Red Hat
Posts: 65

Original Poster
Rep: Reputation: 15
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...
 
Old 01-11-2006, 06:56 AM   #8
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
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 ?
 
Old 01-11-2006, 07:34 AM   #9
Dtsazza
Member
 
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 31
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem executing a linux script from php that runs ffmpeg darkisolde Linux - Software 4 10-04-2005 08:43 AM
issues with mirc script accessing our php script dtra Linux - Software 2 07-02-2005 05:30 PM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 12:51 PM
Red Hat 9 server can't write PHP script, problem in httpd.conf file? x_menno_x Linux - Newbie 27 06-29-2004 05:44 PM
converting shell script to php script ? ibro Linux - General 6 05-24-2004 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration