After going through some trouble to get my Subtext blog running on a Windows Vista installation with SQL Server 2005 I decided to write this how-to so that hopefully other people don't have to go through the same problems.
The instructions explain how to set up Subtext as a Virtual Directory. I also wrote two other articles related to Subtext installation: How to set up Subtext with its own web site instance (like I did with blog.needforgeek.com) on IIS7, and How to compile and debug the Subtext source code on Vista using Visual Studio 2005.
This how-to is split into two parts: Part 1 gets straight to the point and explains step by step how to get everything set up correctly, Part 2 will give some troubleshooting advice if there are still problems. Most people search for a specific error message, so by including the error messages this post is more likely to be found by someone who needs help.
0. Starting Point
As mentioned in the title the following instructions assume that you have an installation of Windows Vista. I used Windows Vista Ultimate Edition RC1 32 Bit which I got through the Customer Preview Program, but any edition, Beta, RC or RTM, and 32 or 64 bit should work with these instructions.
1. Installing IIS7
On a default Vista installation there is no IIS7, so you need to install the IIS7 components. However, since SQL Server 2005 requires IIS6 backward compatibility, we need to install some more features as described in the knowledge base article.
2. Setting up the Database Server
I used Microsoft SQL Server 2005 Developer Edition, but again the instructions should work pretty much identical for any edition of SQL Server 2005, including SQL Server 2005 Express. Make sure to install SQL Server 2005 Service Pack 2 (note that Express has a separate download), which is needed to resolve authentication problems and other issues in Vista.
After installing SP2, the installer will inform you that even if your account has administrative privileges on Vista you don't automatically get administrative privileges on the SQL Server instance together with a link to add your current user to the SQL Server SysAdmin role. You should do that, otherwise you will have problems connecting to the server or creating the database.
Make sure to start the SQL Server Service after installing SP2, since you have to stop the service to run the update and it will not automatically start it again!
3. Preparing Subtext
After obtaining the latest binaries from the Subtext project web site on SourceForge you should unzip them to a location of your choice. I used version 1.9.2 for these instructions and unzipped the binaries into the default wwwroot folder created by the IIS7 installation.
4. Setting up the Virtual Directory
Open up the IIS Manager from Administrative Tools and expand Web Sites and Default Web Site. If you copied the Subtext binaries into the wwwroot folder, you should see the SubText-126.96.36.199 (or whatever your version is) directory now. Right-click on it and pick Convert to Application (which is basically the same as Add Application only that it prefills the values for you). The most important thing is that you change the Application pool to Classic .Net AppPool, otherwise you will have problems with the handlers and other things.
5. Creating the Database
Start up SQL Server Management Studio and connect to your local database server. Should you have failed to add your account to the SysAdmin role after installing SP2 or should the connection fail, make sure that the SQL Server Service is running and then start Management Studio using the "Run as Administrator" option from the right-click context menu. The connection to the server should now work. Then add your account to the Security -> Logins section and give yourself the SysAdmin role. Then you won't need to use elevated access rights anymore to connect to the server.
Create a new database with the name of your choice. For simplicity reasons I picked the default name SubtextData_1.9, but you can use any name. Make sure to edit the subtextData connection string in the Web.config file if you change the database name.
Now in the Security -> Logins section add a new login for the NETWORK AUTHORITY\NETWORK SERVICE user. Just like on Windows Server 2003 on Vista the NETWORK SERVICE user replaces the ASPNET user that you usually find on Windows XP systems for executing ASP.NET applications. Under User Mapping, check the Map checkbox for your Subtext database and give the account db_owner privileges. You will need that to set up the database.
6. Start Subtext installation Wizard
Open your favorite browser and navigate to the web address you used when you set up the Virtual Directory. If everything worked fine, you should see the Subtext welcome screen which will take you through the rest of the installation process.
Problem: When installing SQL Server 2005 the following messages appears: "This program has known compatibility issues" and "After SQL Server Setup completes, you must apply SQL Server 2005 Service Pack 2 (SP2) or a later service pack before you run SQL Server 2005 on this version of Windows."
Solution: Continue and install SQL Server 2005 SP2 afterwards.
Problem: You receive this warning message for the IIS Feature Requirement on the System Configuration Check page of the SQL Server 2005 Setup program: "Microsoft Internet Information Services (IIS) is either not installed or is disabled. IIS is required by some SQL Server features. Without IIS, some SQL Server features will not be available for installation. To install all SQL Server features, install IIS from Add or Remove Programs in Control Panel or enable the IIS service through the Control Panel if it is already installed, and then run SQL Server Setup again. For a list of features that depend on IIS, see Features Supported by Editions of SQL Server in Books Online."
Solution: Install the necessary IIS7 components according to this Microsoft knowledge base article.
Problem: You receive the following message when navigating to your Subtext web address: "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
Solution: Make sure the SQL Server Service is running. After installing SQL Server 2005 SP2 the service is not automatically started again!
Problem: You receive the following message when navigating to your Subtext web address: "Subtext cannot connect to your backend database. Seems to be a problem with the login."
Solution: Make sure your connecting string points to the right database and that the database exists. The Subtext installation process will create database tables, but not the database itself. If the database exists, make sure the NETWORK AUTHORITY\NETWORK SERVICE user has dbowner rights on the database.
Problem: When running SQL Server Management Studio and trying to connect to your local database server, you get the following message: "Cannot connect to <machinename>. Additional information: Login failed for user '<machinename>\<username>'. (Microsoft SQL Server, Error: 18456)"
Solution: Even if your user has administrative rights in Vista, you don't automatically have them in SQL Server. Start Management Studio using the "Run as Administrator" option from the right-click context menu and connect to the server then. Then add your account to the Security -> Logins section and give yourself the SysAdmin role. Then you won't need to use elevated access rights anymore.