Product Documentation

FairCom SQL for PHP

Previous Topic

Next Topic

Configure PHP 7

PHP is included in many common Linux and Unix distributions. The latest version of PHP 7 can be downloaded from the PHP website.

To configure PHP 7 to run FairCom DB SQL PHP PDO follow these steps:

Note: These instructions are not valid for CentOS versions 6, 7, and 8. If followed, they will render PHP non-operational on those systems. If you are installing on one of those CentOS versions, see Instructions for CentOS.

Before following these steps, you should have first compiled and installed the c-tree PHP PDO extension (pdo_ctsql.so) under your version of PHP, (following these instructions: Compile the PHP PDO Extension).

  1. Open php.ini with your favorite text editor. In most installations you will find the server (SAPI) version of php.ini in /etc/php/apache2/php.ini.
    Note: In Linux installations of PHP, there is often a separate php.ini file for SAPI (PHP served from a web server), and for CLI (PHP run from the Command Line). If you intend to test things from the command line (step 7 below), be sure to make the following changes to the CLI version of php.ini (usually /etc/php/cli/php.ini) as well as the SAPI version of php.ini.
  2. Search for extension_dir.
    • If the extension_dir line is commented out (; on the beginning of the line) leave it that way, because the “make install” step during the build should have copied “pdo_ctsql.so” into the default extension folder
    • If this line is not commented, it's better to copy pdo_ctsql.so into your default PHP extensions directory (the directory listed in the php.ini file).
  3. Search for extensions area and add extension=pdo_ctsql.so to configure the FairCom DB SQL PHP module into your PHP:


    Note: your copy of php.ini might have the extensions end with “.so” and it might not, depending on the version of PHP you are using. For this reason, we recommend that you follow the pattern of the other extensions already listed in the file. For example, find the existing “pdo_mysql” extension line, copy it, remove the leading semicolon, and then change two letters to make it say “pdo_ctsql”...
  4. Save the changes to php.ini and close your text editor. If desired, change the other php.ini file as well.
  5. It is important the libctsqlapi.so file must be in one of the following folders:
    - Its original location when the PHP module was built
    - In a directory part of the library path
    The pdo_ctsql module you just built should already know the location of libctsqlapi.so, because the build added the libctsqlapi.so directory to the pdo_ctsql.so module library path. So, unless you have renamed or deleted the folder, you should be OK. Note that later, in deployment situations, you might need to put libctsqlapi.so in a more generic place (IE: you may have built pdo_ctsql.so on a different machine).
  6. Make sure the previous steps worked by launching PHP, as follows:
    php -v
    No error messages or warnings should be printed.
  7. If you modified the CLI version of php.ini in steps 1-4, you can run the tutorials from the command line, as follows:
    php -f ../tutorials/PHP_Tutorial1.php
    Here is what the correct output of this command should look like:
    <html>
    <head>
    <title>PHP Tutorial 1</title>
    </head>
    <body>
    <h4>INIT</h4>
    Logon to server...<br>
    <h4>DEFINE</h4>
    Create table...<br>
    <h4>MANAGE</h4>
    Delete records...<br>
    Add records...<br>
    Display records...<br>
    <TABLE border=1>
    <TR><TH>Number</TH><TH>Name</TH></TR>
    <TR><TD>1000</TD><TD>Bryan Williams</TD></TR>
    <TR><TD>1001</TD><TD>Michael Jordan</TD></TR>
    <TR><TD>1002</TD><TD>Joshua Brown</TD></TR>
    <TR><TD>1003</TD><TD>Keyon Dooling</TD></TR>
    </TABLE>
    <h4>DONE</h4>
    Logout...<br>
    </body>
    </html>
    If you wish, you can repeat this step for each of the four PHP tutorials.
    It should print the HTML source code of a web page. If an “error in tcp bind 111 - SQLSTATE[20212] ctsqlConnect: -20212 Error in Network Daemon - SQL ERROR [-20212]” error is shown, it means the c-tree server is not running. Start the c-tree server and re-do this step.
    If it says “could not find driver - SQL ERROR [0]”, it probably means that you did not edit the CLI version of php.ini in steps 1-4.

    Testing from the command line allows you to see the error messages, even if PHP fails to launch (because it is misconfigured). Note that the tutorial files do not need to be copied to the web server's documents directory in order to do this test.
  8. From the root shell restart your web server with the following command:
    /etc/init.d/apache2 restart

In This Section

Instructions for CentOS

TOCIndex