Tutorials

Install WordPress on Windows Server 2012 R2 with MariaDB 10.0 in replication

In this guide I will show some simple steps of how to create a WordPress blog on Windows, I am going to do this manual in this guide as I feel that way you learn how all applications have been set up.
If you want to do it the quick way you can simply use: https://webgallery.microsoft.com/apps/WordPress

I used for this setup the following servers that have Windows Server 2012 R2 installed.

wordpress01: 192.168.1.46 / 4GB ram / 2 cpu
mariadb01: 192.168.1.47 / 4GB ram / 2 cpu
mariadb02: 192.168.1.48 / 4GB ram / 2 cpu

Workgroup: ULYAOTH

You can of course just install everything on one server and simply remove the whole MariaDB replication part, and just install do a single database installation of MariaDB on the same server as WordPress.

Now let us get to work!

Step 1: Download MariaDB (Only on the servers mariadb01 and mariadb02)
You can download MariaDB from: https://www.mariadb.org

Step 2: Install MariaDB (Only on the servers mariadb01 and mariadb02)
Start the installation by double-clicking the “mariadb-10.0.12-winx64.msi” file.

You should see a screen like this now:

Just press on next.


On this window click the box before the text “I accept the terms in the License Agreement” of course read the terms first! and then click “Next”.


Everything is fine on this window so press “Next” again.


On this window fill in a “root” password for the mysql admin account and I normally click also “Use UTF8 ad default server’s character set” however if you use plain English you can ignore this one.
And again press “Next”


On this page just leave everything default and press “Next”. (I change the Buffer pool Size to 512mb but this is not required)


Since my two Database servers will not have an internet connection I just click “Next” on this window.


Press on “Install” to start the installation of MariaDB.


Congratulations you now have installed MariaDB so just click on “Finish” to close the installation.

Step 3: Change the MariaDB config files (Only on the servers mariadb01 and mariadb02)
Open “C:\Program Files\MariaDB 10.0\data\my.ini” (Only on the servers mariadb01 and mariadb02)

On mariadb01 under the “[mysqld]” part add the following:
server-id=1
log-bin=mysql-bin
binlog_format=mixed

On mariadb02 under the “[mysqld]” part add the following:
server-id=2
log-bin=mysql-bin
binlog_format=mixed

Step 5: Restart the database servers (Only on the servers mariadb01 and mariadb02)
Just reboot the windows servers to test that mariadb will correctly start automatically and take into affect the new configuration.

Step 6: Open the Graphical MariaDB user-interface (Only on the servers mariadb01 and mariadb02)
Start HeidiSQL this was installed with MariaDB.

You should see a window like this when it is started:

click on “New” at this window


Name your session “MariaDB01” or “MariaDB02” Depending on the server you are, and full in your root password and then press “Save” and then on “Open”.


You should see this now.

Step 7: Create a replication user (mariadb01 only)
Inside the graphical interface click on the “Query” tab next to “Host: 127.0.0.1”.

On the “Query” tab add the following:
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'replication007';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.1.48' IDENTIFIED BY 'replication007';
FLUSH PRIVILEGES;
SHOW MASTER STATUS;

And then press on the run button, so it should look as below:

Mark down the result you will see for me this is
File: mysql-bin.000003
Position: 826

Step 8: Configure the slave inside the graphical mariadb interface (mariadb02 only)
Inside the graphical interface click on the “Query” tab next to “Host: 127.0.0.1”.

On the “Query” tab add the following:
STOP SLAVE;
CHANGE MASTER TO MASTER_HOST='192.168.1.47', MASTER_USER='repl', MASTER_PASSWORD='replication007', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=826;
START SLAVE;
SHOW SLAVE STATUS;

It should look something like:

You can have a look in the results window it should say something like:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

If you do not see this then make sure you change the ip at “MASTER_HOST=’192.168.1.47′” to your “mariadb01” server.

Step 9: Create the WordPress database (mariadb01 only)
Inside the graphical interface click on the “Query” tab next to “Host: 127.0.0.1”.

On the “Query” tab add the following:
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO "ulyaothblog"@"%" IDENTIFIED BY "ulyaoth007";
GRANT ALL PRIVILEGES ON wordpress.* TO "ulyaothblog"@"localhost" IDENTIFIED BY "ulyaoth007";
GRANT ALL PRIVILEGES ON wordpress.* TO "ulyaothblog"@"192.168.1.47" IDENTIFIED BY "ulyaoth007";
FLUSH PRIVILEGES;
SHOW DATABASES;

It should look as following:

Step 10: Test if replication works (mariadb02 only)
Inside the graphical interface click on the “Query” tab next to “Host: 127.0.0.1”.

On the “Query” tab add the following:
SHOW DATABASES;

It should show now the wordpress database on your slave also as below:

Congratulations this was all when it comes to the database part! just remember the information:
Database name: ulyaothblog
Password: ulyaoth007

Of course I assume you changed this accordingly to something else :)!

Now all that is left is to actually create the WordPress server itself so let’s continue.

Step 11: Install IIS
Go to “Server Manager” and choose “Add Roles and Features Wizard” from the list here choose “Web Server (IIS)” also select to install the CGI module! now go further and let it install.

Step 12: Download WordPress
Go to “https://wordpress.org/download/” and download WordPress.
Direct URL: https://wordpress.org/latest.zip

Step 13: Extract wordpress
Extract WordPress to “C:\ulyaoth\wordpress\”

Step 14: Download php
Go to “https://windows.php.net/” and download php from there.
Direct link: https://windows.php.net/downloads/releases/

Please be aware php 64bit that I am using is still experimental, if you will use this in production please go for the 32bit version.

Step 15: Extract php
Extract PHP to “C:\PHP\”

Step 16: Add php to your system path
Right click on “This PC” and choose “Properties” on the right bottom site next to your computer and full computer name click on Change settings.
On the window that opens go to the Advanced tab and click on “Environment Variables”.
At the bottom box called “System Variables” search for “Path” in the list and click on “Edit”
Now a new window should open and at the “Variable Value” at the very end add this to the line “;C:\PHP”

So it should look like this:

If it looks like that just press “OK” three times to save everything.

Step 17: Rename php.ini config
Go to “C:\PHP\” and rename the file “php.ini-production” to “php.ini”.

Step 18: Open IIS Manager and stop the “Default Web Site”

Just press the stop button like you see below in the picture:

Step 19: Create a new website for your blog as shown below
Right click on “sites” in the left part of IIS Manager and click “Add Website”.

Fill it in something like this:

Step 20: Make it so IIS can execute php scripts

While still inside the IIS Manager click on your website then double-click Handler Mappings.
The window should change simply right click and choose “Add Module Mapping”.

Now fill it in as follows:
Request path: *.php
Module: FastCgiModule
Executable: C:\PHP\php-cgi.exe
Name: PHP

If it looks as the picture below press on “OK”.

if you do not see “FastCgiModule” then it means you did step 11 wrong and not installed the cgi module also.

Step 21: Add “index.php” ad a Default Document
While still inside the IIS Manager click on your website and then double-click Default Document.
The window should change simply right click and choose “Add”.

Now fill it in as follows:
Name: index.php

It should look like this:

Step 22: Download Visual C++ Redistributable for Visual Studio 2012
Download installer at the following location: https://www.microsoft.com/en-us/download/details.aspx?id=30679#

Step 23: Install Visual C++ Redistributable for Visual Studio 2012
Double click “vcredist_x64.exe” and install it.


Click on “I agree to the license terms and conditions” and then install.


Press on “Close” to finalize the installation.

Step 24: Edit php.ini
Open “C:\PHP\php.ini” and change the following lines:

Change:
;date.timezone =

To:
date.timezone = Europe/Stockholm

You might want to find your own time zone at https://secure.php.net/manual/en/timezones.php

Also, Change:
;extension=php_mysql.dll

To:
extension=C:\PHP\ext\php_mysql.dll

Step 25: Install WordPress.
Go to your websites domain name for me “https://blog.ulyaoth.net” and follow the steps below.


Press on “Create a Configuration File” to continue the installation.


Press on “Let’s go!” to continue the installation.


Fill in all the information as I did of-course use your information from the previous steps and then press on “Submit”.


On this tab you have to copy all information and copy it inside a notepad and then save the file as wp-config.php in “C:\ulyaoth\wordpress\”
So you should end up with a file like this: C:\ulyaoth\wordpress\wp-config.php

Once done you can press on “Run the install”.


Fill this in accordingly so it has what you wish and then press on “Install WordPress”


Congratulations you have no successfully installed WordPress you can press “Log in” to go to the WordPress control panel.

This was it if you now go to your website so for me “http://blog.ulyaoth.net” you will see WordPress up and running.

As always if you see any mistakes or improvements please let me know! Again you can install WordPress easier as I wrote in the top of the website but by doing it manually you learn some IIS, some php and you have a Master/Slave setup for your database.

I hope it helps someone! 🙂

Related posts

How to install MongoDB 3.0 in replication on Windows Server 2012 R2

Sjir Bagmeijer

How to install MongoDB 4.0 in replication on Windows Server 2019

Sjir Bagmeijer

Install XenForo 1.4 using Nginx and HHVM on Fedora 21

Sjir Bagmeijer