Installing Magento on IISExpress

By admin on 04/08/2013

I'm currently evaluating various ecommerce platforms, the golden child of which lately appears to be Magento.

Giving the system requirements a quick glance I noticed the lack of support for Windows and IIS. I've been very impressed with Microsoft's support for non-MS stuff lately and the ease at which you can get PHP sites up and running with IISExpress and WebMatrix. So I decided to give it a bash anyway and see what happened. Lo and behold I was up and running in a few minutes.

Here's what I did (N.B steps 1-3 are there if you've never used WPI and/or Webmatrix to setup a PHP site before, if you have just jump straight to #4):

1 - Install WPI

Go install the Web Platform Installer, an excellent package-manager like GUI for installing stuff.

2 - Install WebMatrix via WPI

Fire up WPI and search for and install WebMatrix. You don't strictly need it but it makes life a heck of a lot easier.

3 - Install Wordpress via WPI

No that's not a typo. Magento isn't available straight from WPI yet but Wordpress has pretty much the same requirements so setting up an instance of that makes sure you have everything in place (namely php and MySQL). Again, simply search for Wordpress in WPI and let it do the rest (this can take some time if you've not done it before as it will download and install php and mysql behind the scenes for you).

4 - Setup Database

Either using the MySQL command line client or MySQL Workbench execute the following sql to create an empty database and user:


    

CREATE DATABASE magento;

GRANT ALL PRIVILEGES ON magento.* TO "magentouser"@"localhost" IDENTIFIED BY "password";

5 - Download Magento

Download and extract Magento Community Edition to a folder of your choosing.

6 - Let WebMatrix do the rest

Open WebMatrix and select "Open Folder as Site" and locate your extracted Magento root. WebMatrix will see that you're doing ungodly things with non-MS technologies and... politely point out that you're doing such and will offer to configure things to work appropriately, let it.

Hit "Run" in WebMatrix.

Voila! You're rocking the Magento installation in true "it just works" glory.

UPDATE: Logging in on localhost

This isn't specifically an issue with IISExpress but the fix does involve some some IIS related trickery. Once you've installed Magento, there is an issue with logging into the admin area when running on localhost which just bounces you back to the login screen. The problem is related to cookies not being stored when on localhost. Here's the fix for IISExpress:

  • Edit your hosts file (c:\windows\system32\drivers\etc\hosts) to add the entry:
    127.0.0.1 magento.local
  • Edit your IISEXpress config file (C:\Users\[username]\Documents\IISExpress\config\applicationhost.config), find the <sites> node and within that your recently configured magento site. Ensure your bindings look like the following (replace with the port allocated when you set up the site):
    
        

    <bindings>

    <binding protocol="http" bindingInformation="*:59507:localhost" />

    <binding protocol="http" bindingInformation="*:59507:magento.local" />

    </bindings>

    *note we added the 2nd binding

  • In your Magento folder delete the var/cache and var/session directories
  • Restart your browser (you may need to clear your cache/cookies)

You can now use http://magento.local:[portno] to view your local magento installation.