Page 1 of 1

...failed to open stream: Permission denied...

Posted: Tue Jul 15, 2003 12:42 am
by Master Jakkal
Hello fellow PHP Developers,

I am a beginner in need of some help. :oops:
I am trying to install and configure PHP on a Windows XP computer with IIS 5.
Apparently, I was able to install it with a degree of success, but also with some limitations.
I have been getting errors when I try to open certain .txt files and / or run the exec() command.
Here's the error I get when trying to open a .txt file
Warning: fopen(/orders.txt): failed to open stream: Permission denied in F:\Web Root\PHP Test Site\...\processorder.php on line 63
exec() error:
Warning: shell_exec(): Unable to execute 'dir c:' in F:\Web Root\PHP Test Site\test.php on line 9
I've verified the path and set the IIS 5 folder access to Read, Write and Directory Browsing, and Execute Permissions to Scripts and Executables.
The safe_mode in the php.ini file is turned Off.
I am sure I overlooked something. Any help would be greatly appreciated.
Thank you for your time.

Posted: Tue Jul 15, 2003 12:47 am
by Slippy
XP is the problem... use Linux and Apache and it will work fine.

[edit] - sorry I don't mean to be snarky.

PHP wasn't really designed to run in that environment. Somebody decided that it would be nice if they ported it to Windows. Which is probably a good thing because it has sparked a lot more interest with PHP in general.

It does work (usually) except when you start doing fancy things at which point windows starts to break down and cause problems. [/edit]

Posted: Tue Jul 15, 2003 3:22 am
by Heavy
Take a look:
fopen("/orders.txt");
are you trying to reach a file in the web root or the drive root?
Since PHP probably runs off c: it might mean that you are pointing to the file:
fopen("c:/orders.txt");

if you want it from another place, use full pathname, so any default paths aren't used:
fopen("F:/Web Root/PHP Test Site/orders/orders.txt");
...or wherever youv'e got it. Just be sure to include the drive letter in the path.

One more thing. Are you sure PHP understands when you use spaces in path names? In linux (except from the drive letter and the colon) it would have been written like this on a shell prompt:
F:/Web\ Root/PHP\ Test Site/orders/orders.txt

EDIT: The paragraph above is related to bash rather than linux. sorry. It probably has nothing to do with how PHP reads paths.
Slippy wrote:It does work (usually) except when you start doing fancy things at which point windows starts to break down and cause problems.
I don't think fopen() is a fancy thing to do. It should work.

Posted: Fri Jul 18, 2003 12:44 pm
by Master Jakkal
Thanks for the help guys.
Unfortunately, changing my system over to Linux is not an option.
And yes, the path checks out ok. The persmission is simply denied, even thought the folder and files were set to read/write through IIS.

I uninstalled IIS and tried to install Apache and that went ok, but since I don't know much about servers, I got indcredibly frustrated :x when I tried to install the PHP module and couldn't get it to work, as you might have guessed.

Posted: Fri Jul 18, 2003 7:03 pm
by Slippy
There is a lot of good information on this page that should help you install PHP with apache:

http://www.php.net/manual/en/install.apache.php

Scroll down until you see: Installing PHP on Windows with Apache 1.3.x

Use Apache 1.x and not 2.x ... I found this worked better for my purposes (running a simple postnuke & mysql server). Also given the choice I would suggest you using php.exe over the dll method...

Hope it works for you

I also agree with Heavy. fopen() should work under windoze.

It also helps to see the code that you were executing when you got the error message. If you have a sample it may show that you are referencing the file incorrectly... or give some other clue.