How to install WordPress on IIS

WordPress hosting is dominated by linux-based platforms 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:inetpubwwwroot). 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).

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.

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.

READ:  Website Hosting vs Website Builder | Domain.com | Blog

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.

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:WindowsTemp but you can check if your php.ini configuration says otherwise).

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

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

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.

READ:  11 Best Web Hosting Services for Creators and Experts

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>

READ:  How to Create a Free Forum Website

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)PHPv7.0ext).

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: JetLobster ruby local APNs testing tool.