Host WordPress Websites on Windows ServerIs it possible to host WordPress websites on Windows Server 2022? It can seem daunting, especially if you’re accustomed to the Linux environment, which is more commonly associated with WordPress.

As many of you read about my tutorials, I’ve been hosting WordPress on Linux distros but today will be different.

In this guide, I will walk you through the process of hosting WordPress websites on Windows Server 2022 Datacenter.

Prerequisites

Before you begin, ensure you have the following prerequisites in place:

  1. Windows Server 2022: Ensure your server is up and running with the latest updates installed. You can get your Windows Server on Contabo.
  2. Domain: We need to access our WordPress website using a domain. Get an affordable domain on Namecheap.
  3. Internet Information Services (IIS): IIS should be installed and configured on your server.
  4. PHP: The PHP language must be installed to run WordPress.
  5. MySQL: A database server is required to store your WordPress data.
  6. WordPress Files: Download the latest version of WordPress from the official website.
  7. Administrator Access: Ensure you have administrative privileges on your server.

Step-by-Step Guide: Host WordPress Websites on Windows Server 2022 Datacenter

Step 1: Buy a Windows VPS on Contabo

Setting up a Windows VPS on Contabo is very much like Linux. Follow my complete guide here.

If you followed my guide, you should be able to connect to your Windows Server by now.

Contabo New VPS

Contabo Windows VPS Storage Type and Image Windows

Step 2: Get a Domain on Namecheap

Go to Namecheap and register your domain name.

Buy a Domain on Namecheap Web Shanks

Step 3: Install Latest Microsoft Visual C++ Redistributable

Visit the Microsoft Download Center: Go to the Visual C++ Redistributable download page.

Download Microsoft Visual C++ Redistributable

Just follow the on-screen instructions.

Step 4: Install MySQL

Download the MySQL installer from the MySQL website. You can download either installer (web community or community). It will just install MySQL anyway.

MySQL Download

Run the installer and follow the setup wizard.

We don’t need all the products of MySQL. Just the necessary ones so choose Custom.

MySQL Installer Custom

We only need two products. The MySQL Server 8.0.37 – X64 and MySQL Workbench 8.0.36. If they have the later versions, choose them.

Select MySQL Products

The installer will download and install the selected MySQL products and features. Click Execute and follow the on-screen instructions.

Download and Install Selected MySQL Products

MySQL Products Installation

Once the installation is finished, click Next.

MySQL Products Installation Finished

We are now ready to configure the MySQL Server.

Once the installation is complete, the MySQL Installer will guide you through the configuration steps.

Configure MySQL Server

Type and Networking

  • Config Type: Development Computer, Server Server, or Dedicated Computer. Choose the Server Computer because we will be hosting a web application.
  • Connectivity and Advanced Configuration: Remain as is.

Type and Networking

Authentication Method: Choose the authentication method. The default (Use Strong Password Encryption) is recommended.

MySQL Authentication Method

Accounts and Roles: Set the root password and, if desired, create additional MySQL user accounts.

MySQL Accounts and Roles

MySQL User Account

Windows Service: Configure MySQL as a Windows Service. This allows MySQL to start automatically with Windows. You can also choose to start the MySQL Server at the end of the setup.

MySQL Windows Service

Server File Permission: Use the default to grant full access to the user running Windows service and administrator group only.

MySQL Server File Permissions

Apply Configuration: Review the configurations and apply them. The installer will execute the necessary steps to configure MySQL based on your selections.

MySQL Apply Configuration

Finish Setup: Once the configuration is complete, the installer will show a summary of the installation and configuration steps. Click Finish to complete the setup process.

MySQL Apply Configuration Successful

MySQL Product Configuration Complete

MySQL Installation Complete

Connect to MySQL Server: Open MySQL Workbench, create a new connection to your MySQL Server, and log in with the credentials you set up earlier.

Welcome to MySQL Workbench

Step 5: Create a Database

Open MySQL Command Line Client.

From the Start Menu, find the MySQL Command Line Client and open it.

Open MySQL Command Line Client

You will be prompted to enter your MySQL root password. Enter the password you set during the MySQL installation.

Enter your MySQL root password

Create a database. Use the following command to create a new database for WordPress. Replace wordpress_db with your desired database name if you want something different:

CREATE DATABASE wordpress_db;

Check the database creation: To verify that the database has been created, you can list all databases:

SHOW DATABASES;

You should see wordpress_db in the list of databases.

We will now create a MySQL user for WordPress

It’s good practice to create a separate MySQL user for your WordPress installation. Replace wp_user with your desired username and strong_password with a secure password:

CREATE USER 'wp_user'@'%' IDENTIFIED BY 'strong_password';

Grant the new user all privileges on the WordPress database. This allows the user to manage the database:

GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'%';

Apply the changes by flushing the privileges:

FLUSH PRIVILEGES;

Create a MySQL New Database, User for WordPress

Step 6: Install PHP

Download PHP from the official PHP website.

Download PHP

Click the Windows downloads.

Windows Downloads PHP

Download the latest stable release of PHP. Choose the Non Thread Safe (NTS) version if you are using IIS, or Thread Safe (TS) if you are using it with Apache.

We will be using the PHP 8.3.7 NTS.

Download PHP Windows Zip File

Extract the PHP files to a directory on your server, e.g., C:\PHP.

Rename the php.ini-production file in the PHP directory to php.ini.

Now edit php.ini with a file editor. I will be using Notepad++ because it is very user-friendly.

Uncomment the following:

cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
fastcgi.logging = 0
extension=mysqli
extension=pdo_mysql

Now let’s add PHP to the system path.

Open the System Properties and right-click on My Computer > Properties.

Go to Advanced system settings > Environment Variables.

Add PHP to the System PATH

Under System variables, find the Path variable, select it, and click Edit.

Add the path to your PHP directory (e.g., C:\php) to the list. Click OKs once you add the path.

Add the path to your PHP directory

Step 7: Install IIS

With IIS, you don’t need a control panel like cPanel. It’s free on Windows Server.

Open the Server Manager dashboard.

Click on Add Roles and Features.

Add Roles and Features

Follow the wizard and select Role-based or feature-based installation.

Select Installation Type

Choose your server from the server pool.

Select Destination Server

Select Web Server (IIS) and add the required features.

Select Server Roles

Under Application Development, check CGI.

Application Development CGI

Continue through the wizard and click Install.

Select Role Services

Confirm Installation Selections

Download and install URL Rewrite. Choose the x64 installer. we will use this tool to rewrite WordPress URLs.

Next, go to IIS Manager > Select your Hostname > Handler Mappings > Add Module Mapping.

Add Module Mapping

Then click on Request Restrictions and under Mapping tab choose File or Folder.

Module Mapping request restrictions

Request Restrictions Mapping

Next, select your Hostname > Default Document > Add index.php and default.php.

Default Doc IIS

Now we’ll add FastCGI Application.

In the left-hand Connections pane, select your server’s hostname.

In the middle pane, double-click FastCGI Settings.

IIS FastCGI Settings

Click Edit in the Actions pane.

Set the Full Path to C:\php\php-cgi.exe.

Set Instance MaxRequests to 10000 and Max Instances to 0.

Edit FastCGI Application

We will also set our Environment Variables. Set the properties of PHP_FASTcgi_MAX_REQUESTS as Name and 10000 as Value.

Environment Variables

Go to Application Pools and we’ll add a new pool.

Add Application Pool

Right-click the newly created pool and choose Set Application Pool Defaults.

Set Application Pool Defaults

Go to Identity and click the three dots beside it. Use Administrator as username with your machine name. Password is the one you use to login to your server.

Set Pool Credentials

Then test if we have the read/write permissions to the WordPress directory.

Go to Sites > Default Website > Basic Settings > Select the WordPress Application Pool > Test Settings.

The results should be green checkmarks. Otherwise, go back if you missed some steps.

Test Connection IIS

Now we are ready to install WordPress.

Go to wordpress.org and download the latest version.

Extract the WordPress files to your web root directory (e.g., C:\inetpub\wwwroot\wordpress).

WordPress Directory Windows Server

Open the wordpress folder rename wp-config-sample.php to wp-config.php

Open your favorite browser and type in localhost/wordpress. We will begin installing WordPress. It will appear like this. Click Let’s go!

WordPress Installation Windows Server

Do you remember the database name, username, and password you created? We will input those credentials in this step.

Before clicking the Submit button, rename the wp-config-sample.php to wp-config.php.

Configure WordPress Windows Server

Next, we will add some information about our website and create an administrator user. Then click Install WordPress.

WordPress Information Login

Successfully Install WP on Windows Server 2022

Now we have installed WordPress successfully, we will access it with our domain.

So first add two A records for your website. It should be added to your domain registrar.

I’m using Cloudflare so I will add those records here.

A Records Cloudflare for WP on Windows

Now we will bind our IP with our domain. Go to Sites > Add Website and enter the website details.

  • Sitename: Your chosen name for your site.
  • Application Pool: Select the pool we created earlier.
  • Physical Path: Your WordPress installation directory.
  • Binding Type: Choose http.
  • IP Address: Choose your server IP address.
  • Port: Choose 80 for http to work.
  • Hostname: Enter your domain name. It can also be a subdomain.

IIS Add Website WP

Then we will issue an SSL certificate so that we can access our domain with https. To do that go to win-acme and download the latest version.

Win-Acme

Extract the contents of the zip file to a directory on your server (e.g., C:\win-acme).

Run wacs.exe as administrator.

Win-Acme Run as Administrator

Windows Defender will prevent it from running but just click More info and Run Anyway.

Now it will begin creating a certificate.

Follow the steps in the images below.

Win-Acme Create Certificate
Choose N.
Win-Acme Site identifier
Choose the number of the site you want to create SSL for. If you have multiple sites, hit Enter.
Win-Acme Choose Pick all bindings
Choose A.

Then follow the on-screen questions. You will be asked to read the terms and conditions.

Win-Acme Creating Certificate

Go back to your Windows server and go to IIS Manager. Select your domain and click Bindings on the right panel. You should be able to see an https with your domain at port 443.

IIS Bindings WP

Now access your domain with SSL.

WordPress with SSL IIS Windows Server

Now you have your WordPress website hosted on Windows Server 2022 Datacenter!

But that’s not just it. We need to set our WordPress Address (URL) and Site Address (URL) to our domain so we can access our admin page.

Use your localhost to change it because we cannot access it using our domain just yet.

Set Address WP IIS

Now let’s try to access our admin page using our domain.

WP Admin Page Hosted on Windows Server with IIS

The good thing is that the certificate will auto-renew thanks to Window’s task scheduler.

Win-Acme Automatic Renewal

You can set your theme, install plugins, add a logo, create content, and optimize your WordPress site for SEO and speed.

If you want to add more domains to host multiple WordPress websites, just follow steps 5 and 7 or follow this detailed tutorial.

Did you face a roadblock? Comment it down!

Leave a Reply

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