Installing WordPress Locally Using IIS

I recently setup WordPress on my local machine so I could try my hand at developing plugins. It seemed daunting at first, but it turned out to be a fairly easy process.

There are tons of resources available to assist in the installation and setup of WordPress. There are packages available that setup an Apache and MySQL server for you. With those I have found myself spending a lot of time trying to get Apache and IIS to play well together. For me setting up everything in ISS seemed a more elegant solution. My installation of WordPress is specifically geared toward setting it up on a Windows 7 machine running IIS 7 and MySQL 5.5.

There are a few requirements needed in order to get WordPress setup successfully.

I have listed the links above as the versions installed. I highly recommend working with the latest versions as it will make you life easier down the road. I will revisit each of these in turn during this setup process.

WordPress provides an installation guide (http://codex.wordpress.org/Installing_WordPress) that is handy, but for my purposes, was lacking some specific details to get me up and running.

Installing IIS and CGI

There are different ways to navigate the control panel depending on the “View by” setting.  Follow the steps based on which “View by” setting is selected to launch the Windows Features dialog.

“View by” is set to “Category”

  1. Open the Control Panel
  2. Click on “Programs”
  3. Click on “Turn Windows features on or off”

“View by” is set to “Large icons” or “Small icons”

I lumped these two together because the steps are the same only the size has changed.

  1. Open the Control Panel
  2. Click on “Programs and Features”
  3. Click on “Turn Windows features on or off”

Ensure all the necessary items are checked in the Windows Features dialog. There maybe more items checked depending on your current environment. The items mentioned here are what is necessary and/or handy to have to get CGI up and running.




Installing PHP

  1. Download the latest stable non-thread safe Windows binaries (http://www.php.net/downloads.php)
  2. Unpack the downloaded file into a folder of your choice. (i.e. C:PHP)
  3. Rename php.ini-development to php.ini
  4. Open and modify php.ini by uncommenting the following lines and ensuring their values are set properly:
    • fastcgi.impersonate = 1
    • cgi.fix_pathinfo = 1
    • cgi.force_redirect = 1
    • open_basedir = “C:WindowsTemp;C:Inetpub”
    • extension_dir = “ext”
    • extension=php_mysql.dll
    • date.timezone = “America/Chicago”
    • Valid time zones can be found at http://php.net/manual/en/timezones.php

  5. Open a command prompt
  6. Type C:PHPphp -i to verify PHP installation. If it spews all the configuration information then PHP is setup properly

Configure IIS

In order for IIS to host PHP applications a few settings in IIS must be adjusted.

  1. Open the Internet Information Systems (IIS) Manger
  2. Double-click “Handler Mappings” at the server level
  3. Click “Add Module Mapping…” in the Actions pane
  4. Fill in the Add Module Mapping dialog
    • Request path: *.php
    • Module: FastCgiModule
    • Executable (optional): C:PHPphp-cgi.exe
    • Name: PHP via FastCGI

  5. Click “OK”
  6. Click “Yes” to the Add Module Mapping confirmation dialog
  7. Test the new handler mapping
    1. Create a new file named phpinfo.php in the folder C:InetPubwwwroot
    2. Open the file and type
      <?php phpinfo(); ?>
    3. Save and close the file
    4. Open a browser (i.e. Internet Explorer, FireFox, Chrome, etc.)
    5. Navigate to http://localhost/phpinfo.php
  8. Click the server in IIS Manager to return to the “Home” options
  9. Double-click on “Default Document
  10. Click “Add…” in the Actions pane
  11. Type index.php in the Add Default Document dialog
  12. Click “OK”
  13. Create a folder in C:inetpubwwwroot that will hold the physical files that make up your WordPress site
    1. Open Windows Explorer
    2. Navigate to C:inetpubwwwroot
    3. Click “New Folder”
    4. Name the folder for your WordPress site (i.e. MyWordPress)
  14. Click the server in IIS Manager to return to the “Home” options
  15. Expand the Sites node in the navigation tree
  16. Right-click on “Default Web Site”
  17. Click on “Add Virtual Directory…”
  18. Complete the Add Virtual Directory dialog
    • Alias: MyWordPress
    • Physical path: C:inetpubwwwrootMyWordPress


    Alias is what will be typed into the browser to load the WordPress site (i.e. http://localhost/MyWordPress).
    Physical path is the location on the hard drive that holds the physical files that make up your WordPress site.

  19. Click “OK”

Configure MySQL

  1. Install MySQL
  2. Open the MySQL Workbench
  3. Double-click on “localhost” in the SQL Development list (your connection maybe named something differently)
  4. Type in the password for the selected account
  5. Create a WordPress database
    1. Type the following sql commands into the editor:
      /* Create a WordPress database named "MyWordPress" */
      create database MyWordPress;
      
      /*
      Create a database user named "wordpress_user"
      with a password of "wordpress_user123!"
      */
      create user 'wordpress_user'@'localhost'
       identified by 'wordpress_user123!';
      
      /*
      Grant permissions to the "wordpress_user"
      user on the "MyWordPress" database
      */
      grant select, insert, update, delete, create, drop, alter
       on MyWordPress . * to 'wordpress_user'@'localhost';
      
      /* cleanup */
      flush privileges;
      
    2. Click the yellow lightning bolt on the toolbar to run the sql commands
    3. Close the query window by clicking the “x” icon on the query window tab

Configure WordPress

Now that all the back end settings have been set we can move onto actually downloading and installing WordPress.

  1. Download the latest version of WordPress (http://wordpress.org/download/)
  2. Unpack the downloaded file into the physical location of the virtual folder created earlier (c:initpubwwwrootMyWordPress)
  3. Rename the file wp-config-sample.php to wp-config.php
  4. Open wp-config.php in a text editor like Notepad
  5. Update the following settings with your WordPress database settings
  6. define('DB_NAME', 'MyWordPress');
    define('DB_USER', 'wordpress_user');
    define('DB_PASSWORD', 'wordpress_user123!');
    define('DB_HOST', 'localhost');
    
  7. Open a browser (i.e. Internet Explorer, FireFox, Chrome, etc.)
  8. Navigate to http://localhost/MyWordPress
  9. This should redirect you to the WordPress installation page to finalize the WordPress configuration. If it does not navigate to the page http://localhost/MyWordPress/wp-admin/install.php

  10. Complete the WordPress Setup page
    • Site Tite: My Word Press Site
    • Username: admin
    • Password, twice: enter something you can remember!
    • Your E-mail: abc@youremail.com (make sure you actually enter your own email address here)
    • Privacy: leave it checked
  11. Click “Install WordPress”

  12. If everything was configured properly you should see a success page displayed.

  13. Click “Login” on the WordPress Success page

Congratulations! WordPress is now successfully setup on your local machine! You can now login using the admin login you setup on the WordPress Setup page.

After successfully logging into WordPress you will be shown the WordPress Dashboard. Happy WordPressing!

Tagged with: , , , , ,

Leave a Reply