woensdag 11 april 2012

Backing up your IIS 6.0 Metabase

Preface:
In previous versions of Internet Information Services (IIS) configurations were stored in the registry.  Part of IIS 6.0's rebuilding was changing where the configuration is stored, which is now a file named MetaBase.xml in your \WINDOWS\system32\inetsrv directory.  Sure, you can copy that file (and possibly MBSchema.bin.00000000h) to a separate directory, but a smarter way to do this is to use IIS 6.0's built-in back-up mechanism.  There are 2 ways to do this, but I'll only be showing you the graphical one at the moment.
Method:
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).

Right click your computer name, put your mouse over "All tasks" and click "Backup/Restore Configuration"

Click Create Backup

Now you can make up any name you want, not including dots (.)  You can also password protect the back up if you choose

That's it, you're done!  To restore the backup you can now select the backup you just made and press the Restore button

Your backup is stored in C:\WINDOWS\system32\inetsrv\MetaBack under the name you gave it.  Actually, it will be 2 files.  In the example I gave above 2 files were created:
visualwin backup.MD0
visualwin backup.SC0
I recommend the copying of these files to another folder, just in case.

Setting Host Headers in IIS 6.0

Preface:
Many people would like to have several web sites hosted on their own computer, maybe they want something like hello.domain.com and goodbye.domain.com both on the same computer.  IIS can use host headers to see what the end user tried viewing, and it will show the correct web page based on that.
Method:
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).
On the left side, expand your computer name, then click "Web Sites", right click in the right side, put your mouse over "New" and select "Web Site..."
Click Next in the dialog, then put in a description of the new web site you are creating (can be anything)
Now here's the important part.  Go to the last text box and put in what you want the new Host Header to be
Now put in the path to your new site and make sure you keep "Allow anonymous access" checked
For added security, if you don't plan on using ASP or anything similar, then uncheck "Run scripts".  You can always enable it at another time
Click Finish on the next dialog and you're done!
Questions:
Q: How do I add a host header for a site already made?
A: Go back to where we were before.  Click on "Web Sites" and right click the website and select "Properties"
In that dialog click the Advanced button
Now click Add
Put in the TCP port 80 (port 80 is the default website port, so people can type http://some.site instead of having to type http://some.site:port) and your new header below it
Now click OK and OK and you're done!
Q: Do I need to set anything in DNS or my website's Name Servers if I have a top level domain?
A: The answer is yes, you need to add an (A) name, but since all programs are different, I will not display how.

Enabling ASP

Preface:
ASP and ASP.NET are NOT! the same thing.  Some people enable ASP.NET hoping that ASP will work also, this is just not the case.  IIS 6.0 comes with ASP disabled by default, and this will show you how to enable it.
Method:
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).

Go to the Web Service Extensions tab, click Active Server Pages, then press the "Allow" button on the left
Your ASP pages should now work :-)

Setting up PHP-ISAPI on Windows Server 2003

Preface:
I showed you here how to set up PHP using the CGI executable.  Since then I've learnt that the ISAPI DLL may be faster and more secure, so this tutorial will show you how to set up the ISAPI DLL instead.  Credit and thanks goes to Keith W. McCammon for setting this up on his website, http://mccammon.org/php/iis6_install.php .  Made visual with permission from Keith.  Something to note is that these directions had in mind default (unmodified) ACLs/Permissions.
Method:
Unzip the latest PHP ZIP file to C:\PHP, and copy php.ini-recommended from that folder to C:\windows\php.ini, then copy php4ts.dll to C:\Windows\System32
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).

Click the name of your computer then click "Web Service Extensions", on the left side of the main frame you will see a green arrow pointing to a link that says "Add a new Web service extension...", click that link.

Set the extension name to anything you'd like, put C:\PHP\sapi\php4isapi.dll as the Required file, also check "Set status to allowed"

Go to the directory you'd like to configure PHP for in the IIS Manager, right click it, and select properties

Click the Create button, set the Execute permissions to "Scripts only", then click the Configuration button

Click Add.  For the Executable put - C:\PHP\sapi\php4isapi.dll for the Extension put ".php", set the verbs to all, and make sure the bottom check boxes are checked

Click OK and OK

Setting up PHP to work on Windows Server 2003

The following things are pre-assumed:
  1. You are running Windows Server 2003
  2. IIS 6.0
  3. You have installed PHP (http://www.php.net) to C:\PHP (installation issues are at the bottom of this page)
  4. You are using default (unmodified) ACLs/Permissions
Update: Tom McDermid has brought to my attention that in the PHP 5 line, the EXE name is "php-cgi.exe" instead of "php.exe", so when installing PHP 5, remember to replace "php.exe" in this tutorial with "php-cgi.exe"
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).

Click the name of your computer then click "Web Service Extensions", on the left side of the main frame you will see a green arrow pointing to a link that says "Add a new Web service extension...", click that link.

For the Extension name put something like "PHP" in and for the Required Files put "C:\PHP\php.exe", also check to set it to allowed

Now load a command prompt (Start->Run... type cmd) and type "md c:\inetpub\wwwroot\phpscript"

Back in the IIS Manager double-click "Web Sites", click "Default Web Site", right-click the directory "phpscript" and click properties

In the new dialog click Create then Configuration (Configuration will only become enabled after you click Create).  If you don't see .php listed then add it by clicking Add... and setting the following

Click OK and OK and you should be set to run your PHP scripts
Installation issues
Q: I tried installing PHP and got some error about there not being an OCX or something, either way, now I can't execute my scripts :-(
A:  The error you received was stating that an OCX control (ActiveX) that the PHP installer uses wasn't found, don't worry, that's the reason I wrote this tutorial :-)
My reasoning
Q:  Why do you use the Command prompt to make directories when you can just load Explorer and make it that way?
A:  I find it quicker to do by command line, but any method will work.

Setting up Perl/CGI to work with Windows Server 2003

The following things are assumed:
  1. You are running Windows Server 2003
  2. IIS 6.0
  3. You installed ActiveState ActivePerl (http://www.activestate.com/) to C:\Perl UPDATE: ActivePerl 5.8.2 Build 808 and higher should add the Web Service Extensions during install
  4. You are using default (unmodified) ACLs/Permissions
Also, all of my reasoning is explained after the step-by-step is done, at the bottom of the page.
Load IIS from the Administrative tools in the Control Panel by clicking Start -> Administrative Tools -> IIS Manager (or loading the Control Panel, entering the Administrative Tools folder, and double clicking IIS Manager).

Click the name of your computer then click "Web Service Extensions", on the left side of the main frame you will see a green arrow pointing to a link that says "Add a new Web service extension...", click that link.

In that window, where it asks for the extension name you can put anything, like "CGI script" and under the "Required Files" section put the following in (without the apostrophes) 'C:\Perl\bin\perl.exe "%s" %s' click OK to the notification, click "Set status to allowed" and press ok.

Now, load up a command prompt (Start->Run... type cmd) and type (without the quotes) "md c:\inetpub\cgi-bin"

Back in the IIS Manager right click Default Web Site highlight "New" in the pop-up menu and click "Virtual Directory..." in the new menu

Click next to the first dialog in the wizard, then as a the alias put "cgi-bin" and click next then as a path for the next dialog put in "c:\inetpub\cgi-bin".  On the next dialog leave everything checked and check execute and click next

Click Finish to end the wizard.
Now right-click cgi-bin and click properties

Click Configuration in the lower right-hand area of the dialog and make sure .pl is there (if it isn't, add it the way you see it)

Making your scripts work
To make your scripts work the shebang line (#!/usr/bin/perl) should now be #!C:\Perl\bin\perl.exe .  Any reference to any files should be changed from /home/user etc, to c:/home/user or c:\\home\\users - note the double back-slashes.
Also, renaming your .cgi scripts to .pl is highly recommended - it's what I do myself ;-)
Assuming this is all done correctly, you should now be able to run your Perl scripts successfully using Windows Server 2003, and IIS 6.0
My reasoning
Q:  Why do you make cgi-bin in \inetpub and not in \inetpub\wwwroot even though you're going to be making a Virtual Directory there anyway?
A:  The reason I go through these extra few steps are (1) To bring in a Command shell (open one of those and
you immediately look smart, plus it makes things go wwaaayyy quicker) (2) I got it from the *nix world, what can I say, back when I hosted on Linux that's the way the directories were set up, so it stayed with me bottom line is, you don't need it like that, it's just the way I prefer.
Q:  Why do you have a cgi-bin folder at all?
A:  It is always better to keep your scripts separate from your regular files.
Q: If you know that ActivePerl 5.8.2 Build 808 and higher automagically add the service extensions, why do you still have this tutorial?
A: Many reasons.  First, this tutorial isn't only for Perl, but for anything similar. Second, just in case :-)

Adding a Windows 2000 computer to a Windows Server 2003 domain

Preface:
I have already shown you how to add AD users and computers to a Windows Server 2003 Active Directory domain, in this tutorial I will show you how to add a Windows 2000 computer to the domain.  The method for adding Windows XP is basically the same, but I have created another tutorial for XP which is available here.
Method:
On the Windows 2000 computer, go to the desktop and right click "My Computer" and select "Properties"
In the dialog that comes up, go to the "Network Identification" tab and press the "Properties" button
Under "Member of" click the "Domain" radio button, then type the name of your domain without the trialing extension (for example, my domain name is "hello.test" but I only typed in "hello"
Now you will be prompted to put in the user name and password of a Domain Administrator.  Enter the correct information, and press "OK"
Now, wait for about a minute or two and you should receive this message welcoming you to the domain
That's it, press "OK" then "OK", then "OK" in the configuration dialog, and finally "Yes" to reboot and you will be able to log onto the domain using an AD user name and password (not the local 2000 password) to log on.
Additive:
After the 2000 computer boots to Control-Alt-Delete you may need to change it from logging onto itself (which will use the local info) to logging onto the domain.  To do this, press Ctrl-Alt-Del, then the "Options >>>" button on the log on screen.  Then select the domain from the drop-down box
After that you can log on using domain credentials