Install Node.js on Windows

Install Node.js on Windows

Node.js is a lightweight yet extremely powerful open source, cross-platform runtime environment for hosting and running JavaScript applications. Its popularity continues rising alongside with the popularity of JavaScript. The way we are able to develop web applications today has changed drastically from only a “few years” back where JavaScript could only be run in the browser. Today we are able to build big and complex applications in JavaScript and host them in Node.js, where in the past these types of applications had to be written in languages like Java, PHP, ASP, etc.

It’s very easy and fast to get going with Node.js which I’ll demonstrate.

1. First off download the 64bit Node.js msi-installer

2. Follow the installation and install Node.js to the default location (C:\Program Files\nodejs)
Make sure npm package manager is installed as well, as you will need this later on.
Also let Node.js be added to PATH (default), so you can access it from anywhere.

Node.js install on Windows

That’s it!
Open up Command Prompt and try the following:

node -v

Node will tell you which version it’s running:

Node.js version

As you can see, I’m running v.4.4.5 of Node.js

Go ahead and try the following as well

npm -v

Node.js npm version

It displays I’m running npm package manager v.2.15.5

We are now confident that both Node.js and npm are working and we can build our first application.

1. Create the directory C:\Node
2. Create the file “hello.js” in C:\Node with the following content:

[javascript]console.log("Hello World!");[/javascript]

3. In Command Prompt go to C:\Node and run;

node hello.js

Node.js hello world

It’s pretty basic, but we build and ran our first JavaScript application in Node.js.
Now let’s try to expand and host a web application.

1. Create the file C:\Node\server.js and paste the following;

//Include the http module
var http = require(‘http’);

//Create a webserver
http.createServer(function (req, res) {

//Respond to any incoming http request
res.writeHead(200, {‘Content-Type’: ‘text/plain’});
res.end(‘Hello World!\n’);

}).listen(1337, ‘’);

//Log that we started listening on localhost:1337
console.log(‘Server running at’);

2. Standing in C:\Node in Command Prompt start your web application;

node server.js

Node.js server

3. Go to http://localhost:1337/ in your browser (from the same machine running Node.js of course)

Node.js browser

We’ve now created a JavaScript application and hosted it through http with Node.js.
It’s still pretty basic, but the possibilities are endless. For example Ghost – a blogging platform like WordPress, and actually created by one of the former WordPress developers, is a Node.js application.

Reset MySQL root password on Windows

If you have forgotten the root password for MySQL on Windows, it’s fairly easy to reset it back to a preferred password.

There are several ways of doing so. I tried the different options stated in the documentation, but ended up with the following warning

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use –explicit_default_timestamp server option
(see documentation for more details)

The solution to reset the root password for MySQL on Windows I came up with is as follows

1. Create “mysql-init.sql” on C:\
Depending on your MySQL version, paste one of the following sql statements in “mysql-init.sql” and save the file.

MySQL 5.7.6 and later

[sql]ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass’;[/sql]

MySQL 5.7.5 and earlier

[sql]SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘MyNewPass’);[/sql]

2. Open up my.ini, typically located in C:\ProgramData\MySQL\MySQL Server x.x\

Locate the [mysqld] section and add the following line


3. Restart MySQL using the console

net stop mysql
net start mysql

4. Check that your password has changed by running

mysql -u root -p

If your password has changed successfully, delete the file C:\mysql-init.sql so you don’t expose your password. Furthermore, remove the “init-file” line in my.ini

Same method works on Unix/Linux systems, but if you are looking for a more OS specific guide, take a look at the documentation.

Redirect file to URL IIS

With this rewrite rule in your web.config, it’s possible to redirect a user from a specific file to an internal or external URL.
When they enter, they will be redirected to

Note that this requires you have URL Rewrite installed on your IIS.

Place the following rule inside:

Your rule goes here…


Rewrite rule:
<rule name="Redirect file to external url" stopProcessing="true">
<match url="^~/folder/filename\.html$" />
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<action type="Redirect" url="" appendQueryString="false" redirectType="Permanent" />

Install Ruby on Rails on Windows guide

Install Ruby on Rails on Windows guide

I played around with Ruby on Rails and wanted to set up a developer environment with Rails server and Ruby, but didn’t find any straight forward and easy guides, so I wrote one instead. Following this guide you’ll get going developing and running Ruby in 10 minutes.

Download RubyInstaller and Dev kit from
If you run 64 bit, remember to get the 64 bit version of both Ruby and dev kit.

Install Rubyinstaller to C:\Ruby
Check “Install Tcl/Tk support”, “Add Ruby executables to your PATH” and “Assosiacte .rb and .rbw files with this Ruby installation”.

Install Ruby on Rails on Windows guide 01

Extract Dev kit to C:\Ruby\DevKit
Open Command Prompt and CD to C:\Ruby\DevKit


[shell]ruby dk.rb init[/shell]

Install Ruby on Rails on Windows guide 02

Open C:\Ruby\DevKit\config.yml and ensure your Ruby location is included. It’s important that you have a “-” before the path like in the example. Save the file and go back to your Command Prompt.

Install Ruby on Rails on Windows guide 03


[shell]ruby dk.rb install[/shell]

Install Ruby on Rails on Windows guide 04


[shell]gem install rails –no-rdoc –no-ri[/shell]

Install Ruby on Rails on Windows guide 05

Create the directory C:\RubyApps

Install Ruby on Rails on Windows guide 06

CD to C:\RubyApps


[shell]rails new my_app[/shell]

Install Ruby on Rails on Windows guide 07

If you installed the 64 bit version of Ruby, open C:\RubyApps\my_app\Gemfile and replace the tzinfo-data line with:

[xml]gem ‘tzinfo-data’, platforms: [:x64_mingw, :mingw, :mswin][/xml]

. Save the file and return to Command Prompt

Install Ruby on Rails on Windows guide 08

CD to C:\RubyApps\my_app


[shell]bundle update[/shell]

Install Ruby on Rails on Windows guide 09

You are now done and can run your Rails server

[shell]rails server[/shell]

Install Ruby on Rails on Windows guide 10

Open up a browser and go to:


Install Ruby on Rails on Windows guide 11

That’s it. Your rails server is running in the Command Prompt window which is handy for development. There are many ways to make Rails run as a Windows Service, in Apache, IIS, etc. Google it if needed. :)

To get started developing your first Ruby application, I highly recommend this guide by Andrea Pavoni.

I found RubyMine by JetBrains to be a very nice IDE for developing Ruby on Rails applications – check it out.


Solr schema.xml stroed/indexed

When defining fields in Solr schema.xml we can define whether we should be able to only search, show or both search and show data in the fields.
Setting the attribute stored=true means that the field will be shown in the search result. Indexed=true means we can search the field.

Sometimes we want to display data in the search result, but it’s not necessary to be able to search the field. This can be accomplished by setting the field attributes to
stored=true indexed=false

IP restrict Azure website

As for now, it’s not possible to IP/Domain restrict an Windows Azure website from the administration portal. You’ll have to add security rules yourself to web.config associated with your website.

Go to system.webServer section of your web.config and add a security element, if you don’t already have it.
Inside you can configure security rules; “ipsecurity”.
Add the IP address and subnet mask for those IP addresses you want to allow access to your website.
If you need to allow several IP’s, simply duplicate the “ipsecurity” element and edit the IP address.

<ipsecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="" subnetMask=""></add>


Point your own domain to Windows Azure Web Site

Pointing your own domain name to your Windows Azure Web Site is fairly simple and fast, if you know how to. A place where people go wrong or find it difficult is regarding setting up DNS. I’ll try to narrow it down.

Start by logging into Windows Azure portal and head to your website. If you are running a free website, you’ll have to first scale it to either a shared or standard plan. Do this by clicking “Scale” on the top menu, and choose your desired plan.

Windows Azure domain

Now go to the “Configure” tab and press “manage domains”

Windows Azure domain

This popup will tell you instructions how to do, but these can be a bit tricky to understand. What is says, is Windows Azure needs to verify you are the domain name owner of your desired domain. This can be done by adding a CNAME-record to your DNS called

Furthermore we will have to point our A-record to the IP address stated in the popup if we want to redirect to our Windows Azure website. I’m not interested in that to start with. Instead I want to point to my Windows Azure website, where as points to my own webserver.

Let’s head over to our DNS configuration. I’m using GratisDNS, but it doesn’t matter which you use. Configuration can look a bit different depending on your DNS host, but settings are the same.

Because I don’t want to point to Azure but my own server, I have given my servers IP as a-record. If you want to point to Azure, simply create a a-record with the IP address stated in the popup I mentioned previously.

Windows Azure domain

As for the CNAME, it is here we have to make a record, so Windows Azure can verify we are the domain owners. Secondly, it’s also here I create my subdomain pointing to Windows Azure.

Windows Azure domain

As you can see, I have created to point to – this is needed to make it possible for Windows Azure to verify I own the domain
Secondly I have created and pointed it to, making it possible to hit my Windows Azure website, when going to

That’s it. Keep in mind that DNS servers have to update before Windows Azure portal can register changes. Usually it takes a few minutes, but can take up to hours. If Windows Azure can not verify your domain within an hour, possibilities are, that you most likely did something wrong.

To check if DNS settings have passed through, we can bring up Command Line or Terminal.

1. “nslookup”

This will give us the output:

Windows Azure domain

This tells us the IP address and hostname the domain is pointing at. Keep in mind this is the DNS we are connected through. DNS servers has to transfer data to each other, so either ours or Windows Azure’s DNS might not have gotten the changed yet.

You can test other DNS servers, eg. Google’s DNS, by typing “server” followed by “”

Windows Azure domain

As you can see, we are now using the DNS (Google), and both DNS servers receive the same data.

Lets head back to Windows Azure portal > Web Sites > our website > Configure > manage domains
Type in your domain or subdomain, in my case and click the accept button.

Windows Azure domain

If Windows Azure has registered DNS changes, you should now be able to point the domain / subdomain to your Windows Azure website.

Want to know more about setting up DNS records to point at Windows Azure, watch this Azure Friday video with Scott Hanselman and Stefan Schackow.

Create Windows Azure Web Site

If you haven’t played around with Windows Azure yet, head to their signup page and get a free 3 months trial account (Google it).
Even after your trial is expired, you’ll still be able to create 10 free websites per data center (meaning, more than 10, technically).

Windows Azure lets you easily create websites in the matter of seconds, where after you can deploy your content very fast with Web Deploy in Visual Studio or Webmatrix, from a git repository and through ftp, to name some of the possibilities. It’s a convenient way to test your code or even run sites, depending on your website settings and goals.

Free websites are restricted to run as a subdomain under – eg. To map your own domain name to your Azure website, you’ll have to scale your website to either a shared or standard plan (more about that in another topic).

Let’s create our first website!
1. Log into Azure portal by going to

2. Click the big plus icon on the bottom left

3. Compute > Web Site > Quick Create

4. Pick a web site name and choose region (data center) and click “Create Web Site”
(Choose a region where your target audience is located, and remember to choose same region when creating a SQL database. This will make your traffic between website and SQL server free and of course improve performance.)

Windows Azure

In the matter of seconds your website is created and up running. You can see your running sites by clicking “Web Sites” in the menu to the left

Windows Azure

Heading to your newly created website, will show you this welcome screen with help on how to publish content

Windows Azure

In the Azure portal under Web Sites, click your newly created website and go to “Dashboard”. Here you’ll get an overview of resources used and other options. Try to click “Download the publish profile”. This profile contains login credentials for your website. You can either import the profile in Visual Studio or Webmatrix when you publish your site, or you can open it with your favourite text editor. The file contains hostname, username and password to use with FTP.

Windows Azure

This is how the publish profile file looks like. I have marked out the hostname, username and password.

Windows Azure

Enable WCF Windows Server 2012

If you didn’t install HTTP-Activation for WCF Services, you will get a 404 error when trying to access your service directly.
To be able to run HTTP WCF Services, do as follows:

1. Run Server Manager from your task bar or start menu
2. Choose the server you want to install WCF on
3. Scroll down to “Roles and Features” from task drop down
4. On “Add Role or Feature Wizard” dialog, click down to “Features” in the list of pages on the left
5. Expand “.NET 4.5” – if you haven’t installed it already, go back to “roles” and install it first
6. Under WCF Services” check the box “HTTP-Activation”. You can also add other types (TCP, Named Pipes, etc) if you will need them
7. Click “Install”

Enable WCF Windows Server 2012