Compiling PHP As an Apache Module

To install PHP to operate with Apache, compile it as an Apache module.

Prerequisites

Configure Apache so that it recognizes shared modules using the following steps.

Task
  1. Make sure the environment is set up for SAP Sybase IQ.

    Depending on which shell you are using, enter the appropriate command from the directory where SAP Sybase IQ is installed.

    If you are using this shell... ...use this command
    sh, ksh, bash
    ../IQ_16.sh
    csh, tcsh
    ./IQ_16.csh
  2. Configure PHP as an Apache module to include the SAP Sybase IQ PHP extension.

    Run the following commands:

    $ cd PHP-source-directory
    $ ./configure --with-sqlanywhere --with- apxs=/Apache-installation-directory/bin/apxs

    The following example is for PHP version 5.2.11. You must change php-5.2.11 to the version of PHP you are using.

    $ cd ~/php-5.2.11
    $ ./configure --with-sqlanywhere --with- apxs=/usr/local/web/apache/bin/apxs

    The configure script will try to determine the version and location of your SAP Sybase IQ installation.

  3. Recompile the relevant components:
    $ make
  4. Check that the libraries are properly linked.
    • Linux users (the following example assumes you are using PHP version 5):

      ldd ./.libs/libphp5.so
  5. Install the PHP binaries in Apache's lib directory:
    $ make install
  6. Perform verification. PHP does this automatically. All you need is to make sure that your httpd.conf configuration file is verified so that Apache will recognize .php files as PHP scripts.

    httpd.conf is stored in the conf subdirectory of the Apache directory:

    $ cd Apache-installation-directory/conf

    For example:

    $ cd /usr/local/web/apache/conf

    Make a backup copy of httpd.conf before editing the file (you can replace pico with the text editor of your choice):

    $ cp httpd.conf httpd.conf.backup
    $ pico httpd.conf

    Add or uncomment the following lines in httpd.conf (they are not located together in the file):

    LoadModule php5_module   libexec/libphp5.so
    AddModule mod_php5.c
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    The first two lines point Apache to the files that are used for interpreting PHP code, while the other two lines declare file types for files whose extension is .php or .phps so Apache can recognize and deal with them appropriately.

PHP is successfully compiled as a shared module.