How to install WordPress on IIS

published in Tutorials, Web Development
by Arthur Krupa

Wordpress hosting is dominated by linux-based platform using mostly Apache on Nginx setups. But if you need to run a website from a Windows machine or VPS, IIS is probably the right way to go. Although there are some tweaks that have to be made, you can easily get your Wordpress instance running in less than 30 minutes.

Prerequisites:

  1. Microsoft IIS 7 or higher
  2. PHP 7 (recommended version)
  3. MySQL-compatible database

Create a new Site on IIS

Start by creating a new directory for your WordPress website in the default location for IIS websites (usually C:\inetpub\wwwroot\). Download the latest WordPress package from the official website and extract the contents into that directory.

We also need to grant read/write permissions for IIS to the wp-content directory so that WordPress will be able to save and modify files (e.g. when installing plugins or uploading files). Right click on the website directory and open up Properties. Head to Security and click Edit. Then, set the Modify permission for IIS_IUSRS (IIS user group) and IUSR (default IIS user).How to install WordPress on IIS

Next, open the IIS Manager and create a new website in your server instance. You can do that by right-clicking Sites in the left pane and choosing Add new website.

INSTALL WORDPRESS ON IIS

Enter your desired website name (this is just for identification within IIS) and point the physical path to the directory we’ve just created. Next, enter the host name your website will be available from. This can be the domain pointing to your IIS machine or a virtual host you’ve created for local development in the system hosts file. Confirm by clicking OK.

CREATE A NEW SITE ON IIS

 

Your WordPress instance is already running, but we need to assign the IUSR user to it so our site will have the access rights we’ve just specified. In the left pane, select your newly created website and open Authentication on the right. Edit Anonymous Authentication and set IUSR to be the specific user.

iis_authentication

Fix access permission for PHP uploads

At this point our website should be up and ready to run but we need to ensure that IIS has enough access rights to handle PHP file uploads. Otherwise, requests for files uploaded through WordPress will result in an error 500.

The reason for this is that PHP doesn’t set access rights for IIS when moving an uploaded file to the website directory (e.g. /wp-content/uploads). In order to fix this we have to grant Modify access rights for IIS_IUSRS to PHP’s temporary directory (usually C:\Windows\Temp but you can check if your php.ini configuration says otherwise).

Open Properties for C:\Windows\Temp, go to Security and click Advanced. First, click Enable inheritance so access rights can be passed down to files and subdirectories.

How to install WordPress on IIS

 

Next, select IIS_IUSRS on the user list (or add it if not present) and click Edit. Set the Modify permission to IIS_IUSRS (IIS user group) and set it to affect only child objects.

INSTALL WORDPRESS ON IIS

Install WordPress on IIS

You can now go to the domain you’ve specified in IIS and check if the website’s running. Open http://yourwebsitedomain/readme.html for instructions on how to install WordPress on IIS.

After installation there are  couple of things you might want to configure in order to make the most of your WordPress instance.

Enable permalinks

In order to use the user- and SEO-friendly “Pretty permalinks” feature in WordPress, we need to enable URL rewriting. For this to work you need to have the URL Rewrite module for IIS installed.

Next, we need to create a web.config file in the root directory of our website. Add the following rewrite rule to the webserver configuration:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>		
      <rules>
		  <rule name="Wordpress" patternSyntax="Wildcard">
			  <match url="*"/>
			  <conditions logicalGrouping="MatchAll">
				  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
				  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
			  </conditions>
			  <action type="Rewrite" url="index.php"/>
		  </rule>
		</rules>
    </rewrite>
  </system.webServer>
</configuration>

Fix static file serving

By default, IIS is configured to serve only a handful of static files properly (images, plain text files). If you’re planning to use web fonts, SVGs, videos or PDFs, you should declare them in your web.config file like this:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
	  <staticContent>

		<!-- Proper svg serving. Required for svg webfonts on iPad -->
		<remove fileExtension=".svg" />
		<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
		<remove fileExtension=".svgz" />
		<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />

		<!-- HTML4 Web font mime types -->
		<!-- Remove default IIS mime type for .eot which is application/octet-stream -->
		<remove fileExtension=".eot" />
		<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
		<remove fileExtension=".otf" />
		<mimeMap fileExtension=".otf" mimeType="font/otf" />
		<remove fileExtension=".ttf" />
		<mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
		<remove fileExtension=".woff" />
		<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
		<remove fileExtension=".woff2" />
		<mimeMap fileExtension=".woff2" mimeType="font/x-woff2" />
		<remove fileExtension=".crx" />
		<mimeMap fileExtension=".crx" mimeType="application/x-chrome-extension" />
		<remove fileExtension=".xpi" />
		<mimeMap fileExtension=".xpi" mimeType="application/x-xpinstall" />
		<remove fileExtension=".safariextz" />
		<mimeMap fileExtension=".safariextz" mimeType="application/octet-stream" />
		
		<!-- HTML5 Audio/Video mime types-->
		<remove fileExtension=".mp3" />
		<mimeMap fileExtension=".mp3" mimeType="audio/mpeg" />
		<remove fileExtension=".mp4" />
		<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
		<remove fileExtension=".ogg" />
		<mimeMap fileExtension=".ogg" mimeType="audio/ogg" />
		<remove fileExtension=".ogv" />
		<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
		<remove fileExtension=".webm" />
		<mimeMap fileExtension=".webm" mimeType="video/webm" />
		
		<!-- Other types -->
		<remove fileExtension=".pdf" />
		<mimeMap fileExtension=".pdf" mimeType="application/octet-stream" />
		
	  </staticContent>
	  
	  <!-- other settings, e.g. rewrite rules -->
	  
  </system.webServer>
</configuration>

Enable Caching

Caching can significantly speed up your WordPress website by serving pre-generated content without calling PHP scripts and database queries over and over again. This is easily achieved with WinCache and WordPress plugins.

Unfortunately, installing WinCache extension from the IIS homepage may break WordPress plugin updates. This is easily fixed by installing the latest repo version manually.

Download the latest development version from the WinCache SourceForge and extract it to your PHP extension directory (e.g. C:\Program Files (x86)\PHP\v7.0\ext).

Next, you only need to install a WordPress plugin that will handle the caching. Double-check the plugin platform support! As of now, the popular WP Total Cache won’t work with IIS. We recommend using WP Super Cache instead, as it supports IIS and WinCache.

Check out other iOS development tutorials on our blog.

Arthur Krupa CDO, founder

Designer by profession, and an engineer at heart. At Zaven he supervises everything connected with visual communication and user experience. On quiet evenings, he enjoys watching documentaries, playing the piano or reading a book. Arthur has a passion for trekking and climbing, that’s why he catches himself daydreaming about mountains far far away...

Popular posts

3D Touch Peek and Pop Tutorial

3D Touch Peek and Pop Tutorial

With the release of the new model of phones: the iPhone 6s, Apple introduced 3D Touch. It's a functionality that allows the user to interact with the device using pressure. In the "3D Touch Peek and Pop Tutorial", I will show you how to use the Peek and Pop feature in iOS app development.

Read more
3D Touch Quick Actions Tutorial

3D Touch Quick Actions Tutorial

Did you know that the iPhone is able to detect different levels of touch depending on how hard you press? This is all thanks to 3D Touch! Check out how to add 3D Touch quick actions to your iOS apps.

Read more
BDD frameworks (part 3)

BDD frameworks (part 3)

In this series of articles, I am presenting selected BDD frameworks. In this part, I will talk about Spock – a unit testing framework.

Read more
Mobile Apps

Get your mobile app in 3 easy steps!

1

Spec out

with the help of our
business analyst

2

Develop

design, implement
and test, repeat!

3

Publish

get your app out
to the stores

Contact us

Hire us now!

back to top