How Do You Troubleshoot a PHP Error “call to undefined function pg_connect()” So Your Script Can Log into a Postgres Database?

Problem scenario
You are trying to use a .php script on the back end to connect to your PostgreSQL database.  However, you get an error like this when you try to run it:  ‘PHP Fatal error:  Call to undefined function pg_connect() in ‘

Solution
Install php5-pgsql.  For Ubuntu you would run a command like this:  sudo apt-get install php5-pgsql

How Do You Install LAPP Using Ubuntu Linux?

Update October 2020: These were tested to work with Ubuntu 20.x.

Problem scenario
You want to install the four core components that compose the LAPP stack. That is you want to install Apache, Postgres and PHP on Ubuntu Linux (which comes with Perl pre-installed).  How do you do this?

Solution
1.  Install Ubuntu.  If you need directions, see this link.

How Do You Install Apache Web Server on Your Ubuntu Server when You Receive an Error about “no installation candidate”?

Problem scenario
You tried this command: sudo apt-get install httpd
But you got this error message as a result:

“…E: Package ‘httpd’ has no installation candidate”

You tried this command as root:  

apt-get install apache2-bin 2.4.7-1ubuntu4.13

But you get this error message as a result:

Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package 2.4.7-1ubuntu4.13
E: Couldn’t find any package by regex ‘2.4.7-1ubuntu4.13’

How do you install Apache web server on your Ubuntu server?

How Do You Comment out a Line in PHP?

Problem scenario
You want to try some .php scripts or web pages without certain lines of code.  How do you comment out an individual line?

Solution
Use this at the beginning of a line of code: //

Example:  //this text will do nothing in the .php script

To comment out multiple lines, use this at the beginning of the first line: /*
Then conclude the multi-line comment with this: 

How Do You Troubleshoot Connecting to a Postgres Database When You Get the Error “FATAL: Ident Authentication Failed”?

Problem scenario
You are trying to establish a connection with a username and password to a Postgres database using PHP.  You have a PHP file like this:  

<?php
   $host        = “host=127.0.0.1”;
   $port        = “port=5432”;
   $dbname      = “dbname=contint”;
   $credentials = “user=contint password=excellent”;

   $db = pg_connect( “$host $port $dbname $credentials”  );
   if(!$db){
      echo “Error : Unable to open database\n”;

How Do You Fix a PHP Web Page when the Page Is Completely Blank?

Problem scenario
Using a web browser you go to a PHP web page.  There are no errors, but the page is blank.  It is just all white, but you expect content to be rendered (e.g., text should be visible).  The WSOD (white screen of death) is a common problem to troubleshoot in a web browser.  What do you do to see output you want it to display?  

Solution
1.