WordPress image upload issue on Windows 2008

For those of you running WordPress on Windows 2008, here’s a fix that I have been searching a while for.

Have you ever run into the problem of uploading an image in WordPress and then try to access the image and you get the following error?

Server Error
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

500 Internal Server Error

500 Internal Server Error

Here’s the FIX:

Fixing permissions so that images/media/files uploaded via WordPress will properly render.  This is the fix for the infamous “500″ error that is thrown when your server has wrong file permissions and the visual result is all the images you uploaded are “broken images” and won’t display.  Also called HTTP Error 500.50 – URL Rewrite Module Error when you have Detailed errors on.

  1. This problem is caused because PHP first uploads the document to a temporary directory (by default C:WindowsTemp), and then moves it from that directory to the actual /wp-content/uploads/ sub-directory.  What happens is that because IIS does not have any permissions to your “C:WindowsTemp” directory, when the file is uploaded there, then moved by PHP, the file inherits NO permissions.  So when IIS tries to serve out that file from your /wp-content/uploads/sub-directory it throws a 500 error and that is actually a permissions error.
  2. The solution:  on the WindowsTemp folder, grant “modify” permissions to both IUSR and {servername}IIS_IUSRS user / group accounts.
  3. Now when you upload files via PHP and PHP then moves them to the correct directory, the files will have the correct permissions and can be accessed.
  4. Important note #1:  If you already have uploaded files and are getting the dreaded broken images issue, go to the /wp-content/uploads/directory and replace/update the permissions to add access for both user accounts noted above.  That will solve that issue.
  5. Important note #2: as with any change off the defaults for Windows, you do this AT YOUR OWN RISK.  It’s up to you if you want to grant the WindowsTemp directory permissions for those two accounts.  If you don’t PHP won’t be able to upload without the 500 issue (unless you move the PHP temp folder elsewhere and grant those accounts access to the other folder).  Do these changes at your own risk.  Please know what you are doing.
  6. You can also edit the php.ini file and change the location of the “upload_tmp_dir” variable and point it to another location.  It’s up to you how you want to do this, as long as you have the right permissions mentioned above, your WP images and future uploads will work fine.

Thanks to:  http://www.amixa.com/blog/2011/04/29/iis-wordpress-images-500-error/

 

WordPress on Windows with Wincache

For those of you running WordPress on Windows with the 1.1 version of WinCache for php.   Here’s a great article regarding an updated wincache dll.    The 1.1 version has been driving me crazy when updating my plugins.  I would select Update Automatically on a plugin, but it would fail on deleting the old directory.  Then I would have to recycle the app pool and manually download the plugin to install it.

Here’s the link:  http://ruslany.net/2011/04/wincache-and-wordpress-plugin-upgrade-problem/

Running PHP on 64 Bit Windows 2003 using FastCGI

After doing some searching on google, it turns out that you can run PHP 32 bit on Windows 2003 R2 64 Bit using the FastCGI Extension for IIS 6.0.   Also, using FastCGI is actually faster the the ISAPI dll.  The steps for setting PHP up to use the FastCGI Extension are pretty straight forward.

  1. Download & Install the FastCGI Extension for IIS 6.0 from iis.net.  Both 32 bit and 64 are available.
  2. Download the latest PHP build from PHP.net
  3. Install PHP

During the install, make sure to select IIS FastCGI in the web server setup.

PHP Setup - Web Server Selection

PHP Setup - Web Server Selection

After installing PHP, follow the directions found at:

http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/

I’m seeing great performance running under this setup as well.   Hope this helps you.

Good Reference Sites:

http://devzone.zend.com/article/2710-FastCGI-and-PHP-A-Users-Story

http://blogs.msdn.com/vijaysk/archive/2007/11/16/iis-6-0-fastcgi.aspx

http://mvolo.com/blogs/serverside/archive/2006/09/29/Making-PHP-rock-on-Windows_2F00_IIS.aspx