使用PDO创建php数据库连接的正确方法是什么?

Background

I have recently been put in charge of maintaining an almost completed website and backend that is written in 6 or so languages (HTML, javascript, php, java, postgres, python...). I'm good with some of these, but not others (php, javascript).

The Problem

I can't connect the website to the postgres database with php. I've found and modified a file called dbconn.php (which presumably is responsible for connecting to the database) and it looks like this currently:

<?php
    $host = "redshift-cluster-merp.something.region.redshift.amazonaws.com";
    $port = 5430;
    $user = "awsuser";
    $pass = "myfancypassword";
    $dbName = "merpdev";

    $dsn = "pgsql:host=$host;dbname=$dbName;port=$port;";
    $pdo = new PDO($dsn, $user, $pass);
?>

This doesn't create a connection between the website and database. However, I am able to log into the database from the same ip address in terminal via

psql -h redshift-cluster-merp.something.region.redshift.amazonaws.com -U awsuser -p 5430 -d merpdev

And I can also connect via JDBC with similar parameters. Is the file dbconn.php correct or am I missing something?

I imagine the lines with $dsn and/or $pdo might have a syntactic error.