Which server side code (e.g. Classic ASP, ASP.Net, PHP) are you using to develop your site and which CMS (e.g. Drupal) are you using ?
The answer to your question will be different for each system.
Most of the open source CMS have extensive online documentation which explains how to integrate their system into yours.