Building Websites with VB.NET and DotNetNuke 4
上QQ阅读APP看书,第一时间看更新

Installing DotNetNuke (Local Version)

Before you begin installing DotNetNuke, you will need to determine if you have the .NET 2.0 Framework installed. The easiest way is to browse to the following location C:\WINDOWS\Microsoft.Net\Framework and look for a folder that starts with V2.0 (for example: v2.0.50727). If you do not see this folder, then you will have to download the 2.0 version of the .NET Framework. You can find the files at the .NET Framework home site (http://msdn.microsoft.com/netframework/). For our examples, we will be using Windows XP Professional, IIS 5.1, and version 2.0 of the .NET Framework.

Note

In this section of the book, we will only be using the Install Package, which only contains the items that are needed to deploy to a web host: we will be using IIS to host our site. IIS stands for Internet Information Services and is the web server application that will run our web portal. If you have downloaded the Source Package and use Visual Studio 2005 then you do not need IIS to work with DotNetNuke. We will also be using SQL Server 2005 in this discussion. DotNetNuke will work easily with SQLExpress. We will discuss installing and working with the Source Package and SQLExpress when we discuss building custom modules. If you haven’t installed IIS then make sure that it is installed prior to the .NET Framework.

Clean Installation

If this is the first time you are installing DotNetNuke, or you do not want to upgrade from a previous version, then you will want to perform a clean installation. This means that you will have to build your DotNetNuke instance from scratch. This chapter will walk you through all the steps necessary to accomplish this task. If you wish to upgrade DotNetNuke from a previous version, please refer to the Upgrading section towards the end of the chapter.

Downloading the Code

Before we start installing our web portal, we need to download the source code. Go to the DotNetNuke website http://www.DotNetNuke.com. You will be required to register before you can download the code. This step is simple, just click on the Register link in the upper right-hand corner, and fill in the required information. Provide a working email address, as the registration process will send an email that includes a verification code.

Once you receive the email you may continue to the DotNetNuke site, log in, and download the code. You will find the DotNetNuke source by clicking on the Downloads icon. If you want the documentation that comes with DotNetNuke, you will need to download both the Install Package and the Documentation Package. While the file is downloading, take time to explore what the DotNetNuke site has to offer. You will find information that will help you as you build your portal.

Note

When you are downloading, you will also see a Starter Kit for DotNetNuke. The Starter Kit is used to help Visual Studio Developers work with DotNetNuke. We will discuss this download in the Module Development chapter.

Once you have the Install Package downloaded from the site, you can double-click on the ZIP file to extract its contents. Where you extract the file is entirely up to you. Most of the documentation you come across will assume that you extract it to C:\DotNetNuke so for consistency's sake we will do the same.

Setting Up a Virtual Directory

After you unzip the files, you will need to set up a virtual directory in IIS. If IIS is not already installed on your system, you can install it by going to Control Panel | Add Remove Programs | Add Remove Windows Components.

Note

For more information on installing and using IIS, http://www.IISFaq.com, (which utilizes the DotNetNuke framework for its portal) should suffice.

A virtual directory is a friendly name, also called an alias, that allows you to separate a physical folder from a web address and defines the application's boundaries. A virtual directory is needed if your files are not located in the home directory. The home directory for IIS is found at C:\Inetpub\wwwroot (if installed at the default location). The virtual directory, or alias name, is used by those accessing your website. It is the name they type in the browser to bring up your portal so select a simple name.

The following table shows examples of mapping between physical folders and virtual directories. As you can see, we will need to set up a virtual directory for DotNetNuke since its location is outside the home directory, in C:\DotNetNuke.

There are two different ways of setting up the virtual directory:

Using Windows Explorer (the Easy Way)

If you are using Windows XP then the easiest way for you to set up you virtual directory is to go to C:\DotNetNuke, right-click on the folder, and select Sharing and Security.

This will open up the DotNetNuke Properties dialog. Click on the Web Sharing tab and select Share this folder.

Using Windows Explorer (the Easy Way)

This will present you with the Edit Alias dialog box. The dialog box will default to the name of the folder it is in, so if you extracted your file to C:\DotNetNuke, then your virtual directory will be called DotNetNuke. Leave all the default permissions and click OK to save the settings.

Using Windows Explorer (the Easy Way)

Using the Virtual Directory Creation Wizard

In this first step, you will set up your virtual directory using the IIS Manager and the Virtual Directory Creation Wizard. You will find the IIS Manager in the Control Panel | Administrative Tools section. Once you have IIS open, drill down until you see Default Web Site, right-click and select New | Virtual Directory.

Using the Virtual Directory Creation Wizard

Click Next to begin the wizard. Then, enter an alias for your website. Type in DotNetNuke and then click Next.

Using the Virtual Directory Creation Wizard

The next dialog box will ask you for the physical location of your DotNetNuke files. This is how IIS matches the virtual directory alias name to the web application files.

Using the Virtual Directory Creation Wizard

Type C:\DotNetNuke in the Directory: field and click Next. On the Access

Permissions page, leave all the default permissions and click Next to save the settings.

Using the Virtual Directory Creation Wizard

Click Finish to exit the wizard.

Using the Virtual Directory Creation Wizard

Verifying Default Documents

Default documents allow you to access a web page by typing in just the folder name. DotNetNuke uses default.aspx as its default page when running the portal. To ensure default.aspx is specified as a default document for your virtual directory, scroll down in IIS until you find the DotNetNuke Virtual Directory. Right-click and select Properties.

Verifying Default Documentsvirtual directorysetting up using Virtual Directory Creation Wizard

Select the Documents tab and confirm that you see default.aspx (in addition to default.asp) in the box. If you see it, click OK to close the properties box.

Verifying Default Documentsvirtual directorysetting up using Virtual Directory Creation Wizard

If default.aspx does not exist, click on the Add button to type it into the Default Document Name box and click OK. This will successfully complete the setup of the virtual directory for DotNetNuke.

Verifying Default Documentsvirtual directorysetting up using Virtual Directory Creation Wizard

Note

If you have both versions of the .NET framework (1.x and 2.x) installed on your computer, you will need to tell IIS which framework to use with this website. On the ASP.NET tab you will need to change the ASP.NET version to the 2.x version of the framework as shown below.

Verifying Default Documentsvirtual directorysetting up using Virtual Directory Creation Wizard

Setting Security Permissions

ASP.NET web applications will usually run using the built-in ASPNET account. To allow the extensive file uploading and skinning features in DotNetNuke, you will have to set some security permissions before they start working correctly. To change these permissions, open up Windows Explorer and browse to your DotNetNuke folder (usually C:\DotNetNuke). Right-click the folder, select Sharing and Security from the menu, and click on the Security tab. Add the appropriate user account and set permissions as discussed below.

If you are using Windows 2000 (IIS5) the account that needs permissions on the DotNetNuke folder is the {Server}\ASPNET user account, where {Server} is the name of your machine running the DotNetNuke installation. It must have read and write permissions for the DotNetNuke folder. If you are using Windows 2003 (IIS6), then instead of the ASPNET account you will need to give permissions to the NT AUTHORITY\NETWORK SERVICE user account. Again, it must have read and write permissions for the folder. Also, if you use Windows authentication, you need to give the full control permissions to the local user.

Note

On an XP machine formatted to NTFS that is not part of a domain, the security tab may not be visible by default. To reveal the Security tab, open Windows Explorer, and choose Folder Options from the Tools menu. On the View tab, scroll to the bottom of the Advanced Settings and clear (click) the checkbox next to Use Simple File Sharing. Click OK to apply the change. You should now have a Security tab when viewing the properties of a file on an NTFS volume.

Setting up the Database

With DotNetNuke 4.3.3, you have a few options available to you when creating your database. If you are using SQL Server 2005 Express edition, you do not need to set up the database manually, since the DotNetNuke database will be attached during the installation process. In the Custom Module Development chapter we will be using SQLExpress as our datastore. To create the database for DotNetNuke to store data about our site, we will be using Microsoft SQL Server 2005 Express Edition. We will be using the SQL Server Management Studio to accomplish this task. For the Management Studio, click on the Start button, and go to Programs | Microsoft SQL Server 2005 | SQL Server Management Studio. Sign on to your server and drill down the (local) server by clicking on the plus (+) signs, right-click on Databases, and select New Database.

Setting up the Database

Type DotNetNuke into the Database name field and click OK.

Setting up the Database

It will take a few moments for your database to be created. This will generate the system tables and stored procedures. The actual tables and procedures needed to run DotNetNuke will be created when you run the program for the first time. Once you create your database shell, you will need to rename and modify your web.config file to connect to SQL Server. Browse to C:\DotNetNuke and find a file named release.config. Select this file and rename it to web.config.

Setting up the Database

Note

In earlier versions of DotNetNuke the web.config file could be found in the main DotNetNuke folder (C:\DotNetNuke in our setup) but to avoid the accidental overwriting of this file when doing an upgrade, you will find that the file will be given an initial filename of release.config.

When renaming is complete, use Notepad to open up the web.config file. We will explore this file in detail while discussing the DotNetNuke architecture; for now we are only concerned with a few sections of the code. The web.config file is an XML-based file so be careful while working with this file.

Within the web.config file, locate the<connectionStrings> section. In this section you will notice that there are two<add> tags, which are both named SiteSqlServer. The first one (the default) is for SQL Server Express. To use SQL Server Express, you would need to comment out the second key. Commenting in the web.config file is done using the opening tag <!-- and the closing tag -->. The example below shows the original<connectionStrings> section in the web.config.

<connectionStrings>
<!-- Connection String for SQL Server 2005 Express -->
<add
name="SiteSqlServer"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;"
providerName="System.Data.SqlClient" />
<!-- Connection String for SQL Server 2000/2005
<add
name="SiteSqlServer"
connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;"
providerName="System.Data.SqlClient" />
-->
</connectionStrings>

We then need to enter the data for our SQL Server. Add the server name (Server=), database name (Database=), user ID (uid=), and the password (pwd=) so that our application knows how to connect to our server. This information will be based on how you have set up your SQL Server.

Next, we need to find the<appSettings> section and modify some more keys. The first thing you will notice is that the SiteSqlServer key is in this section as well. In order for our modules to connect to the database, you will need to fill out the information in these keys as well. For SQL Server Express 2005 you will again need to comment out the SQL Server 2005 version. Make sure you add the server name (Server=), database name (Database=), user ID (uid=), and the password (pwd=) so that our application knows how to connect to our server.

<appSettings>
<!-- Connection String for SQL Server 2005 Express - kept for backwards compatability - legacy modules -->
<add key="SiteSqlServer" value="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Database.mdf;"/>
<!-- Connection String for SQL Server 2000/2005 - kept for backwards compatability - legacy modules
<add key="SiteSqlServer" value="Server=(local);Database=DotNetNuke;uid=;pwd=;"/>
-->

The next set of keys in the<appSettings> section is for the template that is used when setting up your site for the first time. A template is used to create the default look and feel of your site. By default, the base DotNetNuke template is used to

create your site. If you would like to use any of the other templates, you will need to replace (comment/uncomment) the appropriate key.

<add key="InstallTemplate" value="DotNetNuke.install.config" />
<!-- Alternative Install Templates (included in package)
<add key="InstallTemplate" value="Club.install.config" />
<add key="InstallTemplate" value="Personal.install.config" />
<add key="InstallTemplate" value="SmallBusiness.install.config" />
-->

We will be using the default DotNetNuke template so we will not modify this section.

There are a few other optional settings that we may be concerned about at this time:

  • The AutoUpgrade key: This is set to true by default and is used to determine if the upgrade/install process will run automatically.
  • The UseDNNConfig key: This key is set to true by default and tells the installation if it should look in the database or the install file located in the install folder to determine if it should upgrade. This is implemented to reduce the number of calls to the database and improve performance.
  • The InstallMemberRole key: This key is set to true by default and is used to determine whether or not to install the Membership Provider database tables for our installation. If you are sharing a database with another application that uses these tables then you would want to set this to false. We will leave it set to true for our installation.

There are many other settings located in the web.config file but for our basic implementation, we only need to be concerned with the items above. We will look at more of this information when we discuss the DotNetNuke architecture later in this book.

Once this is complete save the web.config file and you are ready to run DotNetNuke for the first time.

To do this, navigate to http://localhost/DotNetNuke in your browser. The first time you access your portal it might take a few moments to come up. This is because it is running the database scripts required to set up your SQL Server database.

While the install process is proceeding, you will see a step-by-step explanation of the process appear on your screen.

Setting up the Database

Once all the scripts have run, you will see the message below:

Setting up the Database

Once you click on the Click Here To Access Your Portal link you should finally see your DotNetNuke Portal.

Setting up the Database