The Ruby PostgreSQL interface (AKA pg gem) is just a thin shell around the PostgreSQL client libraries. You need to install PostgreSQL client libraries and headers, or you cannot install pg gem. You do not need a full installation of PostgreSQL on your application server, but only client development libraries, the package is probably called something like "libpg-dev" or "libpq-dev".
source share