This recipe shows you how to import a line layer into PostGIS and create a routable network out of it, which can be used by PostGIS's routing library, pgRouting. (For details about pgRouting, please visit the project website at http://docs.pgrouting.org.)
The installation of PostGIS with pgRouting won't be covered in detail here because instructions for the different operating systems can be found on the project's website at http://docs.pgrouting.org/2.0/en/doc/src/installation/index.html.
If you are using Windows, both PostGIS and pgRouting can be installed directly from the Stack Builder application, which is provided by the standard PostgreSQL installation, as described at http://anitagraser.com/2013/07/06/pgrouting-2-0-for-windows-quick-guide/.