Tourist visas are available at the Phnom Penh or Siem Reap airports for $30. You should arrive with a passport photo if you wish to purchase a visa this way. You can also apply for an Evisa online at www.evisa.gov.kh - this is an option which allows you to register all your details and apply for a visa approval letter. This will make the process quicker on arriving to the airport as you’ll already have been approved for the visa.
If crossing by land then it's likely that the bus company you'll be travelling with will offer to fast track your Visa for you. This'll cost you about $5 dollars more and pretty much 95% of people on the bus we crossed the border on took this option.
However, for those more adventurous, you can quite easily do this yourself. Just head over to immigration office when you are crossing with a passport photo and some cash and you'll be processed in a matter of minutes. This is literally all the tour operators do. Chances are you won't even need the passport photo but its always worth having one spare, for any border crossing. This way you'll save yourself $5 as well.
Be careful of all the fake 'officials' standing around at the borders with their little badges that like toy police badges. I can't imagine how anyone could not realise these are not real officials, but if in doubt be sure to only ever hand over cash inside the immigration office to the staff behind the desks.