1) Create a 16x16 pixel graphic and save in the ICO file format. If you have Photoshop you'll need to download a plugin to let you save as ICO, or use some other graphic program that can save ICO.
2) Name the file "favicon.ico". It is the same filename for any website.
3) Place the file in the web root of your site.
That's it, the rest is automatic, no code to use or anything like that. They are tricky to get to refresh but in time browsers will use it. I've changed them and it seems like forever before it gets picked up!