Recently I have had to setup WordPress on a couple of Windows servers so I thought I would post a walk-through for anyone trying to do the same. I am not going to go into detail on every step as I am assuming you have some knowledge of windows server and hopefully know your way around.
Step 1 ) Install IIS server with CGI support.
Step 2 ) Download PHP 7 non-thread safe version from http://windows.php.net/download for your architecture either x86 or x64.
Step 3) If you have a 64bit load of Windows (and who doesn’t nowadays) then you need to download both the 32bit and 64bit versions of each of the following Visual C++ runtimes. Download the appropriate version of C++ to support the version of PHP you just downloaded from http://windows.php.net/download. The version of C++ you need is listed in the description such as VC14 x64 Non Thread Safe PHP 7.1 (7.1.9). With this download, you need to download and install VC14 which is Visual C++ 2015. The visual C++ versions are listed on the left side of the above page along with the links to download the x86 or x64 version of each. You can grab the 32-bit or 64-bit version of VC14 here. https://www.microsoft.com/en-us/download/details.aspx?id=48145
Step 4) Download Mysql Community Server from https://dev.mysql.com/downloads/windows/installer/5.7.html The installer is 32-bit but installs either the 32-bit or 64-bit version of MySQL depending on your system. You DO NOT have to register or sign up to download MySQL. Just choose the option “No thanks, just start my download.” at the bottom of the download screen.
Step 5) Download Wincache 2.0.x to enable caching on your server from https://sourceforge.net/projects/wincache/files/development/ Make sure you get the 2.0.x version which matches your version of PHP (7.1, 7.2) or else you will get errors. At the time of this article, wincache requires visual C++ 11 to be installed. You can grab the 32-bit or 64-bit version of VC 11 here. https://www.microsoft.com/en-us/download/details.aspx?id=30679
Step 6) Download URL rewrite for IIS https://www.microsoft.com/en-us/download/details.aspx?id=47337
Now that you have IIS with CGI support installed and all of your other files downloaded, lets setup Visual C++, PHP 7 and MySQL.
Installing Visual C++
Step 7) Install required Visual C++ versions.
- Double click on each visual C++ package you downloaded and install it. You should be installing 3 versions of C++.
Step 8) Install PHP and Wincache Manually
- Extract all files in the PHP .zip package to a folder of your choice, for example, C:\PHP7\.
- Extract Php_wincache.dll from the wincache-126.96.36.199 exe you downloaded to the PHP extensions folder (\ext), for example C:\PHP7\ext.
- Open Control Panel, click System, and then click Advanced system settings.
- In the System Properties window, select the Advanced tab, and then click Environment Variables.
- Under System Variables, select Path, and then click Edit.
- Add the path to your PHP installation folder to the end of the Variable value, for example;C:\PHP7. Click OK.
- Open IIS Manager, select the hostname of your computer in the Connections panel, and then double-click Handler Mappings.
- In the Action panel click Add Module Mapping.
- In Request path, type *.php.
- From the Module menu, select FastCgiModule.
- In the Executable box, type the full path to Php-cgi.exe, for example, C:\PHP7\Php-cgi.exe.
- In Name, type a name for the module mapping, for example, PHP7 FastCGI.
- Click OK.
- Select the hostname of your computer in the Connections panel and double-click Default Document.
- In the Action panel, click Add. Type Index.php in the Name box, and then click OK.
- Click Add again. Type Default.php in the Name box, and then click OK.
- Open your PHP directory and find the php.ini-production file.
- Rename the file to PHP.ini. Now in order to make PHP work on windows, we need to make a few changes to this file so open PHP.ini in notepad or the text editor of your choice. Find and uncomment the following lines in PHP.ini by removing the semicolon from the beginning of the line and change the settings as shown below:
cgi.force_redirect = 0
fastcgi.impersonate = 1
Set extension_dir to the ‘ext’ folder in the PHP folder (i.e. ‘C:\PHP7\ext\’).
max_execution_time = 180 (you may have to adjust this time depending on any PHP scripts or backup programs that need a longer runtime than the default 30 seconds)
memory_limit = 256M (adjust as needed, I set mine up to 256M for WordPress plugins to use)
date.timezone should be set to the time zone of your server (eastern would be America/New_York – You can find a list of appropriate values at http://php.net/manual/en/timezones.php.)
opcache.enable=1 (turns on Zend Opcache)
Go to the bottom of the file and add the following
wincache.fcenabled = 1
wincache.ocenabled = 1
wincache.ucenabled = 0
wincache.fcachesize = 64
wincache.fcndetect = 1
wincache.maxfilesize = 256
wincache.chkinterval = 10
wincache.enablecli = 1
wincache.ucachesize = 8
wincache.scachesize = 8
In order for PHP to function with MySQL, you will also need to uncomment the following lines in the Windows Extensions section.
extension=php_curl.dll (Enables WordPress to retrieve and display product news updates. If disabled, you’ll see an error message in admin every time you log in.)
extension=php_mbstring.dll (Multi-byte string – required by some programs)
extension=php_mysql.dll <– no longer needed??
extension=php_mysqli.dll (Mysql database support)
extension=php_gd2.dll (Enable to see PHP charts)
Step 9) Test your PHP installation
- Open Notepad as Administrator.
- Type the following <?php phpinfo(); ?>
- Save the file as C:\inetpub\wwwroot\phpinfo.php.
- Open a browser and enter the following URL: http://localhost/phpinfo.php
- You should see a page showing you your current PHP settings if everything is working correctly.
Step 10) Installing MySQL
- Update 2/9/19 – If you are installing MySQL 8 you need to read this follow up post first!
- Extract the files from your MySQL download and run setup.
- You only need a few things from the installer so chose the Custom setup type from the first screen. Choose the version of the server itself (x86 or X64), MySQL Workbench and Notifier, which you can use to alert you to any change in the server’s status.
- Click Next
- Click Execute and wait for everything to install. If you didn’t install all of the Visual C++ components earlier, you might need to install the Microsoft Visual C++ 2013 Runtime in order to complete the installation. The Installer will notify you of this or any other failing requirements and give you the chance to fix them without stopping the installation.
- Click Next
- Click Next 3 time until you get to Type and Networking.
- Choose Server Machine (Server Computer for MySQL 8.x) for the config type.
- Click Next
- On the Accounts and Roles screen, you need to enter a Root password. I suggest you make this something unique and hard to guess and be sure to WRITE IT DOWN SOMEPLACE where you can find it that’s NOT on the Web server.
- Click Next
- Leave the defaults as they are shown below. Click Next
- Click Next
- Now on the last screen Click Execute to get all of this stuff configured.
- If everything went well you will have a green checkmark beside each step.
- Click Finish
- Click Next
- Click Finish again to exit the MySQL installer.
- After the installation finishes, it will open MySQL Workbench where you will probably get the following error message. You can just ignore this message.
- Click on the part of the screen where it says “root localhost:3306” and you should get a sign in box.
- Hopefully, you remembered and wrote down the root password you created earlier. Enter it in the password box now to make sure that you’re able to login to your new database server.
- Next, we need to create the WordPress database and user. You can do this from MySQL Workbench or the MySQL command line. MySQL can be managed either from MySQL Workbench or from the MySQL command line client. I am going to show you how to do it from the command line just because it is quicker and easier and I only have to take one picture!
- Open the MySQL 5.7 Command Line Prompt from the Start menu and type in the password that you set for the MySQL root account.
- Update 2/8/19 *** WARNING! If you installed MYSQL 8.x view this updated post before you proceed to the next step! ***
- Now we are going to create the MySQL database for WordPress to use and create a user and give them full access to this database. Type the commands exactly as seen below but change yourdatabasename to whatever you want to call your database and yourwpuser to whatever username you want and password to whatever password you want to use. NOTE: If you copy the lines below, you will have to change the single quote ‘ character after you paste it into a document on your computer as the font on this site changes it to an invalid character for MySQL. It is a single quote, the one below the double quote on most keyboards.
- CREATE DATABASE yourdatabasename;
- USE yourdatabasename;
- CREATE USER ‘yourwpuser‘@’%’ IDENTIFIED BY ‘password‘;
- grant all privileges on yourdatabasename.* to ‘yourwpuser‘@’%’;
- FLUSH PRIVILEGES;
- Type ‘exit’ to leave MySQL and then ‘exit’ again to exit the command prompt.
With these commands, you create a WordPress database and set it as the default in your MySQL session. Then you create an administrative user for WordPress and grant that user all privileges on the WordPress database. You will need this username and password later when we install WordPress. WRITE IT DOWN SOMEPLACE where you can find it that’s NOT on the Web server.
Step 11) Configuring IIS for WordPress
Before we can install WordPress, we need to make a few changes to permissions on IIS in order for WordPress to install and to update plugins and such after it is up and running.
- Browse to C:\inetpub and right click on wwwroot.
- Click on properties
- Click on the Security tab.
- Click the Edit button.
- Click the Add button.
- If your server is on a domain, you will need to click the Locations button, enter your name and password, then click on the server name at the very top of the list before attempting the next step.
- Enter IUSR in the object names box and press OK.
- With IUSR highlighted, click on the Modify box which will place a check beside all of the permissions except Full Control and click Apply then OK.
- Install the URL Rewrite program you downloaded from Microsoft at the start of this article.
Step 12) Installing WordPress
The last step is to install WordPress on your IIS web server. The latest version can be downloaded directly from WordPress.org (https://wordpress.org/download/). The installation is very easy and fast. They have a “famous 5-minute install”. So let’s get to it.
- Unzip the file you downloaded from WordPress into your c:\inetpub\wwwroot folder or you can create a subdirectory in the wwwroot folder and put all the WordPress files in this folder in case you want to install other sites on this server.
- Rename the wp-config-sample.php file in the WordPress directory and name it wp-config.php. Open this file in notepad and change the following settings, substituting the MySQl database username and password that you created earlier. Replace the fields in red below with your info.
- /** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
- After you’ve made these changes, open your browser and go to your website address. For example: http://mywebsite.com. If you extracted WordPress into another folder be sure to adjust the URL accordingly. This will start the WordPress installation script in the PHP file. For example: http://mywebsite.com/mytechblog
- You should be greeted with a language selection to get started. Choose your language and click Continue.
- Click Let’s go!
- Enter your Database name (you already created it earlier), username and password for Database (created earlier). You can change the table prefix if you want, but you don’t need to unless you are going to be using more than one WordPress site. Click Submit NOTE: The page below will not show up if you manually edited the above wp-config.php file.
- Click Run the install.
- Enter your Site Title. Create a username and password for the administrative user for WordPress. Use only strong passwords (long with special characters included) because this part is accessible from the internet. WRITE THE NAME AND PASSWORD DOWN AND SAVE IT SOMEPLACE YOU CAN FIND IT! Click Install WordPress.
- If all goes well you should see Success! Click Log In.
- You will now be taken to the administration part of your WordPress installation (login with the user and pass just created).
- And here you are at the backend of your new site. This is the default page for the administrator when they log in.
- Now if you enter localhost or your sites web address in your browser you should see the default WordPress page.
- Delete install.php from your WordPress/wp-admin folder after install finishes.
The rest is up to you! Happy WordPressing! PHEW!