Subject Connecting from Apache CGI app
Author David Cornelius
I've done a bunch of Firebird programming and have had no problems connecting to a database on Windows or Linux for stand-alone applications or from PHP in a web page. But I'm trying something new and have run into a permissions problem I cannot figure out.

I'm writing a CGI application under Apache on Linux and no matter what I try, I get the error, "Unable to complete network request to host "localhost". Failed to establish a connection. Permission denied."

This is on a local development copy of CentOS, so I've done everything I can to eliminate every possible connection and permissions problem: using the IP address instead of localhost, moving the database file, setting the permissions of the database and folder to global read/write, etc.  I've checked the port, apache configuration, and even disabled the firewall (which already was letting 3050 through).

It happens to be written in Free Pascal using the TIBConnection components, but I don't think this has anything to do with FP. I think it has something to do with Apache and the user limitation of running a CGI application. I set the group of the CGI app to firebird and the group of the database file to apache. I made a link to the library inside the cgi-bin folder, and checked the apache configuration for folder options. I can't think of anything else to try.

After searching the internet for hours, I've found lots of info for connecting to Firebird from apps and lots of info on writing CGI apps, but I have yet to find anything about connecting to a Firebird database from an Apache CGI app. My tests successfully connect to the database from a stand-alone application and I can use the CGI app to do non-Firebird things, so I know I have the basic concepts in place--it's just when I combine them, I hit a brick wall.

I'm using Firebird CS 2.1.7 64-bit on CentOS 6.6 64-bit.

Is it possible for a CGI app under the Apache web server to connect to a local Firebird database?

David Cornelius
Cornelius Concepts