Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » Database and application deployment » Requirements for deploying client applications » PHP client deployment

 

Installing the PHP extension on Linux/Solaris

Copy the shared object from the SQL Anywhere installation directory and add it to your PHP installation to use the SQL Anywhere PHP extension on Linux or Solaris. Optionally, add an entry to your PHP initialization file to load the extension so it does not need to load manually in each script.

Prerequisites

You must have PHP 5.0 or later installed.

 Task
  1. Locate the php.ini file of your PHP installation, and open it in a text editor.

    Locate the line that specifies the location of the extension_dir entry.

    If the entry does not exist, it is recommended that you create the extension_dir entry and point it to an isolated directory for better system security.

  2. Copy one of the php-5.x.y_sqlanywhere shared objects from the lib32 or lib64 subdirectory of your SQL Anywhere installation to the directory specified by the extension_dir variable in the php.ini file.

    Your choice of shared object depends on the version of PHP that is installed, and whether it is a 32-bit or a 64-bit version.

    Note

    The string 5.x.y is the PHP version number corresponding to the version that you have installed.

    If your version of PHP is more recent than the shared object provided by SQL Anywhere, try using the most recent shared object provided. A version 5.2.x SQL Anywhere PHP extension will not work with a version 5.3.x PHP.

    For information about which version of the shared object to use, see PHP extensions.

  3. Add the following line to the Dynamic Extensions section of the php.ini file to load the SQL Anywhere PHP driver automatically. Without this step, the PHP driver needs to be loaded manually every time the script requires it.

    The entry must identify the shared object you copied, which is either:

    extension=php-5.x.y_sqlanywhere.so

    or, for the thread-safe shared object:

    extension=php-5.x.y_sqlanywhere_r.so

    5.x.y represents the version number of the PHP shared object copied in the previous step.

  4. Save and close php.ini.

  5. Verify that your PHP execution environment is set up for SQL Anywhere.

    Depending on which shell you are using, you must edit the configuration script for your web server's environment and add the appropriate command to source the SQL Anywhere configuration script from the SQL Anywhere installation directory.

    In this shell... Use this command...
    sh, ksh, or bash . /bin32/sa_config.sh
    csh or tcsh source /bin32/sa_config.csh

    The 32-bit version of the SQL Anywhere PHP extension requires the bin32 directory to be in your path. The 64-bit version of the SQL Anywhere PHP extension requires the bin64 directory to be in your path.

    The configuration file in which this line should be inserted is different for different web servers and on different Linux distributions. Here are some examples for the Apache server on the indicated distributions:

    • RedHat/Fedora/CentOS   /etc/sysconfig/httpd

    • Debian/Ubuntu   /etc/apache2/envvars

    Note

    The web server must be restarted after editing its environment configuration.

Results

The SQL Anywhere PHP extension is supported on your Linux/Solaris environment and ready for use.

 See also