Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add writing permission to PHP on IIS 7

I need a PHP script to have writing permission in a directory. PHP 5.3 is running as FastCGI under IIS 7 with windows server 2008 as OP. On my php error logs, I got "permission denied" when the script attempts to write a file.

How can I sort this out? I tried to give all right to IIS_IUSR and to IUSR_myservername (with a right click on my folder) but it didn't work.

Any help would be very appreciate,

Regards,

Julien

like image 631
JuCachalot Avatar asked May 04 '11 17:05

JuCachalot


People also ask

How do I grant permissions in IIS?

To grant a user permission to a site or an application, select the site or application and then open the IIS Manager Permissions feature to configure the users who are allowed to connect to that site or application.


2 Answers

I have the same setup and I have to give write permission to:

  • IUSR
  • IIS AppPool\<<AppPoolName>>
like image 69
tomfumb Avatar answered Sep 19 '22 22:09

tomfumb


Actually, it's a little bit more complicated.

The first thing to do is to create a simple PHP file on the concerned website. (It's important to create the file on the concerned website because each website can have a different setting.) The content of this file should be:

<?php var_dump(ini_get('fastcgi.impersonate')); ?> 

Navigate to this file using a browser.

** Case 1 **

If your browser shows :

string(1) "1" 

Then, you need to execute the following command (you need to replace "Default Web Site" by the name you gave to your website in IIS) :

%windir%\system32\inetsrv\appcmd.exe list config "Default Web Site" ^ /section:anonymousAuthentication 

You will receive an answer which looks like this :

<system.webServer>   <security>     <authentication>       <anonymousAuthentication enabled="true" userName="IUSR" />     </authentication>    </security> </system.webServer> 

The information you are looking for is the value of the username attribute of the anonymousAutthentification tag.

  • If this value is not empty, its content is the name of the user you need to give write permissions to.
  • If this value is empty or if the attribute is simply missing, you need to give write permissions to IIS AppPool\AppPoolName (replace "AppPoolName" with the name of your website's application pool).

** Case 2 **

If your browser shows :

string(1) "0" 

You need to give write permissions to IIS AppPool\AppPoolName (replace "AppPoolName" with the name of your website's application pool).

like image 26
Tristan CHARBONNIER Avatar answered Sep 16 '22 22:09

Tristan CHARBONNIER