Many distributions of PostGIS are equipped with pgRouting already, so there is a chance you have it installed without even knowing. Execute the following SQL to check whether you have pgRouting onboard:
select pgr_version();
If you do not get an error, but info on the pgRouting version, then you're good to go.
If you happen to not have the extension available, you need to obtain it first. To do so, navigate to http://pgrouting.org/download.html and follow the instructions for your OS. Once you have the binaries set up, enable the extension by executing the following:
CREATE EXTENSION pgrouting;
At this stage, we should be ready to continue our journey with pgRouting.