Notas del Terrible
Terrible Bore

Making PHP faster on IIS7

March 16, 2010 11:28 by terR0Q

Almost triple performance increase of PHP processing on IIS7 was a result of some simple actions: Zend Optimizer installation (and making it work with FastCGI) and providing full access to C:\Windows\Temp for account used by PHP. And the latter action was found after me seeing all the generated garbage after turning display_startup_errors on...

One more important note: I made new separate installation of PHP (non-thread safe version), then installed Zend Optimizer pointing to this new PHP source, and then added *.php handling in IIS7 again directing to new PHP installation. Same didn’t work on PHP version provided with Windows Server 2008 by default.


IIS7 and WordPress uploaded files

December 20, 2009 21:33 by terR0Q

Recently I solved some problem with WordPress under windows hosting.

Symptoms

When we upload some file, some picture for instance, that goes to wp-content/upload folder everything works ok, picture is resized, and nothing fails. But then we try to open that file from server using direct link and get error 500.

Cause and fix

I found that all uploaded files had IUSR (used by PHP) account among others witch access granted whilst Network Service (IIS uses this account) had no access to these files. That was strange, ‘cause all image previews have correct access list that is inherited from folder as should any file created there.

But the very reason is that PHP uses temporary folder for uploaded files and copies them to destination upon success. This transit folder is set in php.ini (upload_tmp_dir setting) and by default that is C:\Windows\Temp. When files are copied in NTFS, ACL is being copied with them. Network Service account had no access to Temp directory and as a result had no access to all files transferred through it.


So fix is easy: give Network Service all grants necessary in directory set as upload_tmp_dir.


Tags: , ,
Categories: Settings | Web
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

IIS Default Document

November 18, 2009 03:44 by terR0Q

I found one simple yet effective hint to speed up IIS requests processing when I've been merging several PHP application to IIS server from Linux hosting. Result is as good as both common caching and compression.

We need “Default Document” section from web node tabs.

Default list order is pretty dumb: php and aspx files are at the bottom.

Although this list is tiny changing its order and moving index.php up led to multiplied page load speed increase: from one or even several seconds of waiting before page load even starts to unnoticeable milliseconds. That's on dedicated virtual server.

I made no further test for ASP.NET application and I always move Document.aspx up when setting up new web node (that's on IIS 6 BTW, so better change order on my IIS 7 servers…). But the same trick should do for ASP.NET as well as the whole problem is on server side, not on application.

Checked only on IIS7.


Tags:
Categories: Settings
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

BlogEngine.NET, Umbraco, IIS7 Integrated

October 22, 2009 14:58 by terR0Q

One more note for happy usage of BlogEngine.NET with Umbraco in the root with IIS 7 Integrated mode.

We need to add several handlers and modules in web server config node (system.webServer) and remove Umbraco modules inherited from root config. For that purpose write following code into BlogEngine config file:

   1:      <system.webServer>
   2:   
   3:          <security>
   4:              <requestFiltering allowDoubleEscaping='True'/>
   5:          </security>
   6:   
   7:          <modules runAllManagedModulesForAllRequests='true'>
   8:              <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
   9:              <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
  10:              <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
  11:              <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
  12:              <!--Remove the default ASP.NET modules we don"t need-->
  13:              <remove name="PassportAuthentication"/>
  14:              <remove name="Profile"/>
  15:              <remove name="AnonymousIdentification"/>
  16:          </modules>
  17:   
  18:          <handlers>
  19:              <add verb='*' name='File' path='file.axd' type='BlogEngine.Core.Web.HttpHandlers.FileHandler,BlogEngine.Core' />
  20:              <add verb='*' name='Image' path='image.axd' type='BlogEngine.Core.Web.HttpHandlers.ImageHandler,BlogEngine.Core' />
  21:              <add verb='*' name='Syndication' path='syndication.axd' type='BlogEngine.Core.Web.HttpHandlers.SyndicationHandler,BlogEngine.Core' />
  22:              <add verb='*' name='Sitemap' path='sitemap.axd' type='BlogEngine.Core.Web.HttpHandlers.SiteMap,BlogEngine.Core' />
  23:              <add verb='*' name='Trackback' path='trackback.axd' type='BlogEngine.Core.Web.HttpHandlers.TrackbackHandler,BlogEngine.Core' />
  24:              <add verb='*' name='Pingback' path='pingback.axd' type='BlogEngine.Core.Web.HttpHandlers.PingbackHandler,BlogEngine.Core' />
  25:              <add verb='*' name='OpenSearch' path='opensearch.axd' type='BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler,BlogEngine.Core' />
  26:              <add verb='*' name='Metaweblog' path='metaweblog.axd' type='BlogEngine.Core.API.MetaWeblog.MetaWeblogHandler,BlogEngine.Core' />
  27:              <add verb='*' name='RSD' path='rsd.axd' type='BlogEngine.Core.Web.HttpHandlers.RsdHandler,BlogEngine.Core' />
  28:              <add verb='*' name='CSS' path='css.axd' type='BlogEngine.Core.Web.HttpHandlers.CssHandler,BlogEngine.Core' />
  29:              <add verb='*' name='JS' path='js.axd' type='BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler,BlogEngine.Core' />
  30:              <add verb='*' name='Rating' path='rating.axd' type='BlogEngine.Core.Web.HttpHandlers.RatingHandler,BlogEngine.Core' />
  31:              <add verb='*' name='OPML' path='opml.axd' type='BlogEngine.Core.Web.HttpHandlers.OpmlHandler,BlogEngine.Core' />
  32:              <add verb='*' name='BlogML' path='blogml.axd' type='BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler,BlogEngine.Core' />
  33:              <add verb='*' name='SIOC' path='sioc.axd' type='BlogEngine.Core.Web.HttpHandlers.Sioc,BlogEngine.Core' />
  34:              <add verb='*' name='APML' path='apml.axd' type='BlogEngine.Core.Web.HttpHandlers.Apml,BlogEngine.Core' />
  35:              <add verb='*' name='FOAF' path='foaf*.axd' type='BlogEngine.Core.Web.HttpHandlers.Foaf,BlogEngine.Core' />
  36:          </handlers>
  37:   
  38:          <validation validateIntegratedModeConfiguration='false' />
  39:   
  40:      </system.webServer>

And to disable Umbraco web configuration inheritance move system.web, system.web.extensions, applicationSettings and system.webServer nodes into location node with inheritInChildApplications attribute:

<location path="." inheritInChildApplications="false">   

Btw, location trick can be useful in many other situations. Unfortunately it can’t solve inheritance problem with configSections node.