Add Windows Authentication Provider IIS 7 Windows 7
http://weblogs.asp.net/zroiy/archive/2008/08/17/missing-windows-authentication-provider-for-iis-7-on-windows-server-2008.aspx describes how to set up Windows Authentication providers in IIS 7 on Windows 2008; the image below shows how it's done in Windows 7
Parsing and analysing IIS W3C log files
There are three methods I've used to parse and analyse IIS W3C log files in the last couple of weeks. AWStats, Log Parser, and SQL Server.
Option 1: Use AWStats
http://awstats.sourceforge.net/
Free real-time logfile analyzer to get advanced statistics (GNU GPL). This can be used on the command line and produces graphs and stats in webpages. To install and get stats from your first log file will probably take 1-2 hours.
Option 2: Use Log Parser 2.2 from Microsoft
http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en
"Most software is designed to accomplish a limited number of specific tasks. Log Parser is different... the number of ways it can be used is limited only by the needs and imagination of the user. The world is your database with Log Parser."
Microsoft, I can't believe you really just said that.
Anyway the Log parser is a handy tool, even more so because you can query log files themselves using SQL like syntax. This one only takes about 10 minutes to download and install, and you can be pulling useful numbers out of it within about 5 minutes.
Option 3: Use SQL Server Management Studio
Create a table similar to the following (depending on the format of your log)
CREATE TABLE [dbo].[tablename] (
[date] [datetime] NULL,
[time] [datetime] NULL ,
[c-ip] [varchar] (50) NULL ,
[cs-method] [varchar] (50) NULL ,
[cs-uri-stem] [varchar] (255) NULL ,
[cs-uri-query] [varchar] (2048) NULL ,
[sc-status] [int] NULL ,
[sc-bytes] [int] NULL ,
[time-taken] [int] NULL ,
[cs(User-Agent)] [varchar] (255) NULL ,
[cs(Cookie)] [varchar] (2048) NULL ,
[cs(Referer)] [varchar] (2048) NULL
)
Populate it using this command
BULK INSERT [dbo].[tablename] FROM 'c:\data\my.log'
WITH (
FIELDTERMINATOR = ' ',
ROWTERMINATOR = '\n'
)
(code taken from http://support.microsoft.com/kb/296085)
If you already have SQL Server Management Studio installed this method is useful, especially due to the familiar syntax (SQL)
Running Powershell scripts on a new PC
When running Powershell scripts for the first time on a developer PC, you will need to change the execution policy for Powershell.
By default the behaviour only allows signed scripts to run.
Executing
Set-ExecutionPolicy RemoteSigned
will allow locally developed scripts to be executed.
More information about Set-ExecutionPolicy can be found at http://technet.microsoft.com/en-us/library/ee176961.aspx until Microsoft changes their URLs yet again
Forgot the root password on a Debian box?
The author points out that using single user mode on Debian is not the solution - but this is very simple and straightforward if you are able to edit the boot configuration in grub on your Debian box.
http://www.debianadmin.com/how-to-change-root-password-in-debian.html
archive (tar and gzip) with timestamp in bash
#!/bin/bash
tar zcf "$1-archive-$(date + '%F-%H-%M').tar.gz" "$1"
Windows Powershell recursing, regular expressions, and sorting
On a project I'm currently working on, I was looking for unused JavaScript files in the scripts/ subdirectory. The easiest way to do this was by checking for references to these files in all other files in the project.
PS E:\projects\source\tickets\trunk> Get-ChildItem Website\* -recurse | Select-String -pattern "scripts\/.+js" |% { [regex]::Replace($_, ".*(scripts/.+js).*", "`$1" ); } | sort -unique
Apache displaying PHP source – update httpd.conf
If Apache is displaying the source of your PHP files, try adding something similar to your MIME module in httpd.conf:
Note - this refers to PHP5 & Apache 2.2. Ensure you are using the correct binary (php5apache2_2.dll) for your php / apache combination.
LoadModule php5_module "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\php5apache2_2.dll" AddType application/x-httpd-php-source .phps AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt
Backups and Blat not sending attachments properly
I wrote a batch file to
* Dump MySQL databases and Subversion repositories
* Zip those files using 7 zip
* Email them using Blat
This was all working fine until my attachments reached about 5mb. At this point, I started receiving funny looking messages like this
begin 644 archive-2008-21-12-15-54.zip
M4$L#!`H``````,-^E3D````````````````(````4W1A9VEN9R]02P,$%```
M``@`PWZ5.66F^"0XN`,`V@H+`"P```!3=&%G:6YG+V%V:64M<F5P;W-I=&]R ...
Blat was automatically splitting large messages into multiple parts.
Suppressing this functionality using -nomps stopped the mail from being sent at all!
Checking my log revealed
Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19)
Message is too big to send. Please try a smaller message.
MailEnable was advertising an attachment size limit of 5mb.
If you are using MailEnable, you can alter the attachment size limit by opening MailEnable Administrator, clicking on "MailEnable Management", "Servers", "localhost" (or your server name), "Connectors", and right clicking on "SMTP". The message size limit setting is on the Inbound tab.
Installing PHP 5 on IIS 6 on 64 bit Windows
When setting up this blog on my new VPS, I had some trouble configuring PHP 5 on IIS6. I have installed PHP on Windows/IIS successfully a number of times in the past so this came as a surprise.
For the first time I was installing on an x64 operating system, and this does make a difference to the installation process.
Running PHP on 64-Bit Windows from the IIS Admin Blog noted the first issue was "trying to load a 32-bit application (in this case PHP) inside a 64-bit worker process"
In order to configure IIS to run in 32-bit mode you need to execute the following command :
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs
SET W3SVC/AppPools/Enable32bitAppOnWin64 1
There are a number of helpful steps and screenshots available at http://www.iisadmin.co.uk/?p=14
Secondly, I added PHP5 to my list of Web Service Extensions.
* Navigate to the IIS Manager in whichever management console you prefer (I usually run compmgmt.msc)
* Open the Web Service Extensions panel
* Etiher click "Add a new Web service extension..." or right click in the current pane and click on the context menu item of the same name.
* Type a sensible extension name such as PHP5 into the "Extension name" box
* Click Add and navigate to your copy of php5isapi.dll
* Check "Set extension status to Allowed"
* Click OK
The IIS Admin blog has an alternative way to do this (on the command line). From the article How To Install PHP on IIS 6.0:
cscript iisext.vbs /AddFile c:\PHP\php5isapi.dll 1 PHPISAPI 1 “PHP ISAPI”
Restart IIS if necessary, and PHP5 should be ready to go.