Solving Problems with WordPress on Windows Server (IIS)


Notice: A non well formed numeric value encountered in C:\inetpub\wwwroot\wp-content\plugins\crayon-syntax-highlighter\crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in C:\inetpub\wwwroot\wp-content\plugins\crayon-syntax-highlighter\crayon_formatter.class.php on line 119

Notice: A non well formed numeric value encountered in C:\inetpub\wwwroot\wp-content\plugins\crayon-syntax-highlighter\crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in C:\inetpub\wwwroot\wp-content\plugins\crayon-syntax-highlighter\crayon_formatter.class.php on line 119

As a follow up to my article about Installing WordPress on IIS, here are a few tips on fixing common problems with running WordPress on Windows Server.

See the previous article here

Slow Page Loading

If you think your pages load slowly especially without catching turned on you can try to change the following settings.  I would recommend that you make this change regardless of whether you think it makes a difference or not. Open the wp-config.php file in the root of the WordPress installation folder. Locate the following line of code:

define(‘DB_HOST’, ‘localhost’);

Change this code to the following:

define(‘DB_HOST’, ‘127.0.0.1’);

As an alternative, you can modify your host file and do the same thing.  Right click on notepad, or your favorite text editor, and “Run as Administrator”.  Now go to “File – Open” and browse to C:\windows\system32\drivers\etc and open hosts.  You will need to change your file selection drop-down in notepad from *.txt to *.* so you will see hosts.

Find the two lines below and remove the # from the beginning of these two lines to make them active and save the file.

# 127.0.0.1  localhost
# ::1  localhost

Your file should now have these two lines at or close to the bottom of the file.  There will be a lot of lines at the top that starts with #.  Do NOT remove the # from these lines.

127.0.0.1  localhost
::1  localhost

The reason for the increase in speed is because by default the hosts file in most Windows installations has the mapping 127.0.0.1 to localhost disabled, so it has to hit DNS each time and figure out the IP address that localhost resolves to.  The 127.0.0.1 is for IPV4 and  ::1 is for IPV6.

Some installations may have this file named hosts.sam. If yours is named this then you must rename it to hosts as hosts.sam is a sample file and is NOT read by Windows.  Change your file explorer view to “show extensions for known file types” or browse to this directory via a CMD prompt to make sure you have this correct.

Maximum File Upload Size

If you tried to upload an image or file to your WordPress site you may have run into an error like “File too large!” or “Upload failed” or “This file exceeds the maximum upload size for this site”. If you have not yet encountered this error, chances are you will at some point.  Your max upload and posts size are usually very small unless you or a plugin has modified them already.  The defaults for a lot of people is set to 2 megabytes. For most users, this is insufficient. This is also an easy fix.

Locate the folder PHP was installed in.  Open php.ini and locate the following line:

upload_max_filesize = 2M  (This 2M may be something else).

Change it to the following:

upload_max_filesize = 128M (or whatever size you need it to be)

Also, find the following line:

post_max_size = 2M  (This 2M may be something else).

Change it to the following:

post_max_size = 128M (or whatever size you need it to be)

Restart your server or IIS service for these changes to take effect. Now your max upload and post size have been increased to whatever you specified on those two lines.

IIS Folder Permissions

There are a couple of folder permissions that can cause a variety of errors with WordPress on a Windows server.  Let’s check those and change them if needed.

Open Windows Explorer and locate the root folder where you have WordPress installed. Right-click this folder, select Properties and click the Security tab. Check and see if IIS_IUSRS exists and that they have the three permissions listed below.  If it is not there, choose Edit then Add.  If you have trouble adding IIS_IUSRS see further down for help.

If you try to add IIS_IUSRS you may run into the following error.

If so, click on the Locations button and choose the server that is listed at the top of the box.

Click OK and you should be able to add this user now and set the appropriate permissions.

WordPress will need special permissions in order to update itself, install plugins and themes, upload pictures, remove session information, and other file writing functions.

Open Windows Explorer and locate the root folder that WordPress is installed in and find the wp-content folder. Right-click this folder, select Properties and click the Security tab.  Check and see if IUSR exists and that they have the permissions listed below.  You should NOT NEED Full control selected.  If it is not there, choose Edit then Add.

Once you have done that, you will need to give the IIS_IUSRS group Read permissions on your “C:\Windows\Temp” folder.

Note: If you have edited your php.ini file and change the upload temp directory then you will need to give IIS_IUSRS group read permissions on that folder instead.

Under some conditions, you may need to give the IIS_IUSRS group modify rights to the “C:\windows\temp” folder or the folder specified in your PHP file. Don’t do this unless there is a need to!

Changing Permalinks Cause 500 Error  –  “500 (Internal Server) Error”

If you changed your permalinks in WordPress/Settings/Permalinks from default to Post Name and saved your changes you may get a message at the top of the page.

“Permalink structure updated. Remove write access on web.config file now!”

You may have read quite a few articles about changing the .htaccess file and tried in vain to fix it that way.  Well, IIS does not use that file and this method won’t fix your problem if you are running Windows Server.  You will need to find your web.config file and fix the issue or rename it (don’t delete it) and create a new one.  This file should be in the root of your WordPress folder. A plain web.config is listed below.  This should get you back into your site, but more than likely there are setting in your current file that you need such as rewrite rules.

If you are using the Rewrite module then this web.config may work for you.

Incorrect time on your site

First, make sure your server has the correct time.  Second, go to your Admin Dashboard and click on Settings then General.  Next, locate the Timezone drop-down button and set it to the correct timezone.  You will see the current date and time below so you can make sure you select the correct one. Be sure to save your settings at the bottom of the page.

 

About The Author

I have worked in the computer repair field since the early 90's. I was a technician and then Coordinator of Computer Repair for Regional Education Service Agency II (RESA 2) for 18 years. I am currently working for Wayne County Schools as a Network Engineer/Technology Specialist. I am responsible for the schools Internet access, Wi-Fi, networks, servers, laptops, desktops, and their operating systems and software.

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *

− three = four