Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP fopen Permission Denied - Windows Server remotely

I have a PHP project in Windows Server 2012 & Xampp 1.8.2. I've tried to read some remote HTML content from another Windows Server 2008 with IIS:

$handle = fopen("\\\\SERVER001\\Webdocs\\page\\index.html", 'r');

...but I have this message:

Warning: fopen(\SERVER001\Webdocs\page\index.html): failed to open stream: Permission denied in ...

But if I'm accessing with the file protocol, works fine:

file://///SERVER001/Webdocs/page/index.html

I've added the IP server in the ipv4 address and domain restrictions option of IIS, I've gotten the same result.

I think is problem of Windows Server 2012 (or apache) because I've tested the same project (localhost) in my PC Windows 7, the same xampp 1.8.2., I've added my IP in the ipv4 address and domain restrictions in the 2008 Server and fopen() works without problems and extra configurations. The only difference from the server and my PC is the OS.

What another thing I do to have permission on this server?

Permissions:

Permissions:

like image 889
csotelo Avatar asked Apr 10 '15 14:04

csotelo


1 Answers

I've found the problem:

apache service in netstat running like a local user

The difference between my PC and Windows Server is my Xampp's Control doesn't have the apache service installed. When this is installed, the Apache service running like a local user (not like a user in the active directory domain).

So is necessary asign a domain user in:

Services > Apache > Properties > Log On tab > This account

Restart Apache and works!

like image 83
csotelo Avatar answered Sep 26 '22 02:09

csotelo