How Do You Troubleshoot a 500 URL Return Code with a PHP Web Page That Is Using pg_connect?

Problem scenario
You have an Apache web server with PHP code.  You are trying to integrate web pages with Postgresql.  When browsing to a web page (.php), you are getting a 500 URL return code.  Your PHP web page file is using the reserved command “pg_connect.”  How do you overcome this 500 URL return code error and have the web page work?

Solution
Possible solution #1:  Reboot the web server.

How Do You Troubleshoot a PHP Page Showing the Raw Code in a Web Browser?

Problem scenario
You created a PHP web page, but it is not rendering correctly in a web browser.  You see the raw PHP code or text.  What do you do to get the PHP to display correctly as a web UI (and not raw code and uninterpreted text)?

Solution
Possible solution #1
Install PHP.  For assistance with installing it on a Debian/Ubuntu server,

How Do You Create a Web Page That Issues Customized SQL Commands to a Database Behind-The-Scenes?

Problem scenario
You want a web page with a text field to enter a single line of SQL code.  You want this code (as opposed to some fixed, pre-written code) to execute.  How do you do this?

Solution
This is more dangerous because SQL injection attacks are a serious problem.  This link is how to have a PHP page execute fixed code.

How Do You Get a Web Page to Invoke a Postgres Command (e.g., for a RESTful API)?

Problem scenario
You want a REST call to invoke some SQL code on a Postgres database.  How do you do this?

Solution
Install Apache web server, PHP, and the PHP-pgsql package on your Postgresql database server.  This example assumes you have PHP, Apache web server, Postgres, and the php-pgsql package installed on your server.  Assuming the web server is running and the default directory for web pages is still /var/www/html/ do the following.

How Do You Deploy LAPP with Frontend User Authentication?

Problem scenario
You want a web page that asks for a username and password (e.g., to log in).  The users will not know if the authentication is done via Apache or Postgres.  You happen want the authentication to be challenged against a Postgres database.  This way if you have backend access to the Postgres database, you can use “CREATE ROLE” or “CREATE ROLE jane PASSWORD ‘veryfun’ LOGIN” to create users.  

A List of Apache Web Server Books

The Accidental Administrator: Linux Server Step-by-Step Configuration Guide by Don R Crawley
Administering Apache by Mark Allan Arnold, Clint Miller, James Sheetz and Jeff D. Almeida
Apache 2 Pocket Reference: For Apache Programmers & Administrators (Pocket Reference (O’Reilly)) by Andrew Ford
Apache Administrator’s Handbook by Rich Bowen, Daniel Lopez Ridruejo and Allan Liska
Apache Cookbook: Solutions and Examples for Apache Administration by Rich Bowen and Ken Coar
Apache Essentials: Install,

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.