Here is a nice video from HouseImprovements on how spray foam insulation can be installed by a homeowner.  Please know that this is intended for educational purposes only.  Installing spray foam oneself can be dangerous if certain safety steps are not followed.