eurica

numbers for people.

Getting PHP to read files over a Windows Network

As part of my continuing penance for crimes real and imaginary, I’m doing some work in a jury-rigged environment where my Apache server needs to read and write to files off a Window Share.

Doing everything that immediately popped into my head didn’t help:

  • Disabling firewalls
  • Changing the permission on the folder
  • Mapping a network drive
  • Voodoo curses

Everything results in:

Warning: fopen(Win7ProTSXWorktest.txt) [function.fopen]: failed to open stream:
Permission denied in C:Sourcejiffy2test.php on line 6

The problem is that Apache & PHP on Windows run as “Local System Account” and that user has no rights on the other machine (not even to view files that “everyone” can read, go figure). In the case I’m looking at, the machines aren’t on a network with Active Directory, so I needed to set up a user on both machines with the same name and password.

You can do that on windows by going to services > Log On:

Set a real user for the Apache Service

Set a real user for the Apache Service

Thanks go to a PHP bug report from 2003.

Comments are closed.