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 » PHP support » SQL Anywhere PHP extension » How to build the SQL Anywhere PHP extension on Unix and Mac OS X » How to compile Apache and PHP

 

Compiling PHP as an Apache module

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

Prérequis

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

Note

Mac OS X comes with a pre-installed Apache web server.

  1. Configure Apache to recognize shared modules.

    Execute commands similar to the following from the directory where your Apache files were extracted:

    $ cd Apache-source-directory
    $ ./configure --enabled-shared=max --enable-module=most --prefix=/Apache-installation-directory

    The following example is for Apache version 2.2.9. You must change apache_2.2.9 to the version of Apache you are using.

    $ cd ~/apache_2.2.9
    $ ./configure --enabled-shared=max --enable-module=most --prefix=/usr/local/web/apache
  2. Recompile and install the relevant components:

    $ make
    $ make install

    Now you are ready to compile PHP to operate as an Apache module.

 Task
  1. Make sure the environment is set up for SQL Anywhere.

    Depending on which shell you are using, enter the appropriate command from the directory where SQL Anywhere is installed (by default, this is /opt/sqlanywhere16). On Mac OS X, the default directory is /Applications/SQLAnywhere16/System.

    If you are using this shell... ...use this command
    sh, ksh, bash
     . ./bin32/sa_config.sh
    csh, tcsh
    source ./bin32/sa_config.csh
  2. Configure PHP as an Apache module to include the SQL Anywhere 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 SQL Anywhere installation. In the output from the command, you should see lines similar to the following:

    checking for SQL Anywhere support... yes
    checking     SQL Anywhere install dir... /opt/sqlanywhere16
    checking     SQL Anywhere version... 16
  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
    • Mac OS X users:

      Refer to your httpd.conf configuration file to determine where libphp5.so is on your computer. Perform the check with the following command:

      otool -L $LIBPHP5_DIR/libphp5.so

      $LIBPHP5_DIR is the directory where libphp5.so is located, according to your server configuration.

      This command outputs a list of the libraries that libphp5.so uses. Verify that libdblib16.so is in the list.

  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
    Note

    On Mac OS X, the last two lines should be added or uncommented in httpd_macosxserver.conf.

    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.

Résultat

PHP is successfully compiled as a shared module.

 See also