Developing for SQLServer and IIS in a virtual machine

This week I’ve been participating in the SQLServer Jump-in Camp. My focus for the workshops have been building out better support for IIS and SQL Server in CakePHP. As I generally develop on MacOS, I do development for other platforms through virtual machines. This has worked well with linux servers in the past. I mount directories to the guest OS using VMWare’s shared folder feature. I figured this same approach would work well with Windows. Turns out in practice to not work well. After connecting the mapped directory in VMWare and settings thing up in IIS. The mapped directory shows up, and feints working, until you restart IIS.

Once restarted IIS starts giving extremely cryptic errors that seem to be related to permissions. I started off getting errors related to missing web.config files. Once that file was in-place, I got errors related to the file being un-readable despite what Windows Explorer said. Thankfully for me, I had access to the people who built IIS and SQLserver to help me out. In the end I never did get the Shared Folders feature of VMWare working, but in its place I got SMB shared volumes working like a charm. The process is a bit twisty, so I’ll explain it.

  1. First you need to enable SMB sharing inside MacOS. Inside System Preferences > Sharing, you need to check off File Sharing.
  2. Once in the File sharing preferences, click the options button to open a dialog where you can enable SMB sharing, and also enable SMB sharing for your specific account. You’ll be prompted for your password, so if you don’t get that
    prompt you missed a step.
  3. Once you’ve got sharing enabled in MacOS, you need to setup Windows 7.
  4. After opening up Windows Explorer, I used Tools > Map network drive to map my SMB share as Y:. I initially tried Z: but cmd and powershell had issues getting to the share when it was mounted as Z.
  5. With the help of the Microsoft engineers, I created a new shadow user account in Windows 7 that had the same username, and password as my host OS user. The reason we had to do this was the SMB share’s need authentication to work, and my understanding was that Windows could only login with users it had on hand. Creating a shadow user allowed everything to work out.
  6. I then created the new site in IIS, and used the mapped drive and correct directory as the new site’s document root.
  7. Again with the help of Microsoft engineers, we configured IIS to use the shadow user account as the Physical Path Credentials, and set the Physical Path Credentials Logon Type to Interactive. Both these options are under the site’s Advanced Settings. They enable IIS to use the shadow user account credentials when trying to access the filesystem, which passes the SMB credentials check.

After all these steps restarting IIS actually worked! It booted up, and served content from the shared SMB drive. There were a few caveats though:

  • Creating files from the Guest OS into the SMB share doesn’t seem to work. For some reason when I create files using PHP in the guest OS, the files don’t stick. All attempts to create files fail, I haven’t had time to look into this, but I bet its permission related.
  • Speed, SMB is not fast, but that has little to do with the solution I came up with and more to do with Samba in general.

Even with the few limitations, I think this is a good solution if you prefer working with your existing tools, and not switching full stop to a new development environment and tool chain. I have to give a big thanks to the people at
Microsoft for the help in getting this solved. I tried once previously and failed miserably. Having people around who know the internals of IIS and SQLServer really helped get things working.

Comments

uffda. sounds like a real nightmare. but i gotta say i am looking forward to an easier-to-use CakePHP in Windows/IIS.

randy on 6/22/11

Just went to the jumpincamp homepage to see an interesting statement:
“70% of small businesses use SQL Server and almost all the larger businesses do.”

I find that a bit hard to believe but I’m no statistician.

Sonic on 6/22/11

Comments are not open at this time.