Accessibility

Table of Contents

Configuring and Testing PHP Servers for XSL Support

Configuring PHP 4.3+ Servers

Before you continue reading this section, you should first consider upgrading your server to PHP 5 for the reasons explained earlier.

If, however, you are restricted to using PHP 4.3.x as your application server or you don't plan for an upgrade, you need to have the following libraries for perform XSL server-side development:

  • libxml (you need at least version 2.4.14)
  • DOM XML
  • libxslt (you need at least version 1.0.18)
  • DOM XSLT
  • zlib (on Mac OS only).

DOM XML and DOM XSLT are two PHP extensions used for processing XML files. To learn more about DOM XML and DOM XSLT, visit the PHP.net website. To run properly, these extensions require the libxml and libxslt libraries from the Gnome project. You can find out more about libxml on the xmlsoft.org website. To learn about libxslt, visit this web page.

Configuring PHP 4.3+ Servers on Windows

The following instructions assume you have already installed a web server with PHP language support on a computer running Windows. Before proceeding with the configuration steps, check if the required libraries are not already enabled on your server by loading the PHP test page in your browser.

As of PHP 4.3, the libxml and libxslt libraries are built-in in the PHP installation. The DOM XML and DOM XSLT support is also included by default, but may be disabled in your particular server configuration. To enable DOM XML and DOM XSLT on Windows operating system, follow these instructions:

  1. Check if the iconv.dll file is located in the system32 subdirectory of your Windows installation. If it's not, copy this file from the dlls folder of your PHP installation to the specified path. This is a character set conversion library required by DOM XML.
  2. Locate the php.ini configuration file for your current PHP installation (usually located in C:\Windows\) and open it using any text editor (such as Notepad).

    Note: You can find out where the PHP configuration file (php.ini) is located on your system by loading the PHP test page containing the server information in your browser. Look for the Configuration File Path setting:

    Figure 5. Locating your php.ini file

    Figure 5. Locating your php.ini file

  3. Search for the following line:

    extension_dir

    Make sure the value of this directive is set to the extensions directory of your PHP installation and this line is uncommented. For instance, if your PHP installation is located in C:\PHP, the line should be:

    extension_dir = C:\PHP\extensions
  4. Search for the following line:

    ;extension=php_domxml.dll

    and uncomment it by removing the semicolon (;) character, to activate DOM XML.

  5. Save the php.ini file.
  6. Restart your web server.

To check if the configuration went smoothly, read Testing PHP 4.3 Servers.

Configuring PHP 4.3+ Servers on Linux

The following instructions assume you have already installed a web server with PHP language support on a computer running Linux. Before proceeding with the installation instructions, check if the required libraries are not already installed on your server by loading the PHP test page in your browser.

  • If libxml is already enabled, you can skip steps 1-4.
  • If libxsl is already enabled, you can skip steps 1-7.
  • If all required libraries are enabled, you can skip this section altogether. Your server is already configured for sever-side development using XML data.
  1. Download the latest version of libxml for Linux from the xmlsoft.org website. The source file you're looking for is called libxml2-2.6.20.tar.gz.

    Note: The version number may be different at the time you download the package. The version used in the following instructions was the latest at the time of writing this article. Make sure you use the version number you have in the next instructions.

  2. Extract the archive contents to a directory of your choice using the following command:

    tar xzvf libxml2-2.6.20.tar.gz

    Linux creates a directory called libxml2-2.6.20, which contains the files for compiling and installing libxml.

  3. To compile and install libxml, you need root privileges (you may have to re-login using the root user).
  4. Go to the libxml2-2.6.20 directory and run the following commands at the command prompt, in the given order:

    ./configure -–prefix=/usr
    make 
    make install

    Libxml is now installed on your server.

  5. Download the latest libxslt version from the xmlsoft.org website. The source file you're looking for is called libxslt-1.1.14.tar.gz.

    Note: The version number may be different at the time you download the package. The version used in the following instructions was the latest at the time of writing this article. Make sure you use the version number you have in the next instructions.

  6. Extract the source archive as you did for libxml, using the following command:

    tar xfz libxslt-1.1.14.tar.gz

    Linux creates a directory called libxslt-1.1.14, which contains the files for installing and compiling libxslt.

  7. Go to the libxslt-1.1.14 directory and run the following commands at the commands prompt, in the given order (make sure you are logged in as root):

    ./configure –-prefix=/usr –with-libxml-prefix=/usr
    make 
    make install

    Libxslt is now installed on your server.

  8. Configure PHP with DOM XML and DOM XSL support. To do that, execute the following commands, in this sequence:
    ./configure \
    --prefix=/usr/local/php \ 
    --with-config-file-path=/usr/local/php \ 
    --with-apxs=/usr/sbin/apxs \ 
    --with-xml=/usr \
    --with-libxml-dir=/usr \ 
    --with-dom=/usr \
    --with-dom-xslt=/usr

    Note: The flags used above only enable DOM XML and DOM XSL support. Add any other flags that might be necessary for your own configuration, such as MySQL support, LDAP, FTP, and so one. Also, the path to your current PHP installation may be different than /usr/local/php, depending on your settings or the Linux/Unix version you are using.

  9. Compile PHP:

    make
  10. Install PHP:

    make install
  11. Restart your web server.

To check if the configuration went smoothly, read Testing PHP 4.3 Servers.

Configuring PHP 4.3+ Servers on Mac OS

The following instructions assume you have already installed a web server with PHP language support on a computer running Mac OS. Before proceeding with the installation instructions, check if the required libraries are not already installed on your server by loading the PHP test page in your browser. In addition to the libraries mentioned earlier, you may also need to install zlib prior to the libxml installation.

  • If zlib is already enabled, you can skip steps 1-5.
  • If libxml is already enabled, you can skip steps 1-11.
  • If libxsl is already enabled, you can skip steps 1-17.
  • If all required libraries are enabled, you can skip this section altogether. Your server is already configured for sever-side development using XML data.

Note: The required libraries are presented in the order they must be installed. Therefore, if you try to install libxml without having zlib, your browser will display an error message and you will have a corrupt installation.

  1. Download the latest source code package for the zlib library. The file you're looking for is zlib-1.1.4.tar.gz.
  2. Extract the zlib library to a folder of your choice, using StuffIt Expander, or the tar command line utility:

     tar xzvf zlib-1.1.4.tar.gz
  3. Open a Terminal window and navigate to the created folder.
  4. Compile the library, using the following command:

    sudo make
  5. Install the zlib library:

    sudo make install
  6. Download the latest source code version of the libxml2 library.
  7. Extract the library to a folder of your choice, using StuffIt Expander, or the tar command-line utility:

    tar xzvf libxml2-2.6.20.tar.gz
  8. Open a terminal window and navigate to the created folder.
  9. Configure the libxml library with the command:

    ./configure –with-prefix=/usr
  10. Compile the library for your system by running the command:

    sudo make
  11. Install the library:

    sudo make install
  12. Download the latest source code version of the libxslt library.
  13. Extract the library to a folder of choice, using StuffIt Expander, or the tar command line utility:

     tar xfz libxslt-1.1.14.tar.gz
  14. Open a Terminal window and navigate to the created folder.
  15. Configure the libxslt library, by issuing the following commands:

    ./configure --with-prefix=/usr/local \
    --with-libxml-prefix=/usrl/local /
    --with-libxml-include-prefix=/usr/local/include \
    --with-libxml-lib-prefix=/usr/local/lib
  16. Compile the library for your system, by running the following command:

    sudo make
  17. Install the library on your server (you need to know the root password):

    sudo make install

    Note: Alternatively, you can use a bundled package of the libxml and libxslt libraries. Installation instructions are provided here.

  18. After installing all the required libraries, you need enable them in PHP, by running the following commands:

    ./configure –with-zlib-dir=/usr/local \
     --with-dom –with-dom-xslt=/usr/local  --with-apxs

    Note: The flags used above only enable XSL support. Add any other flags that might be necessary for your own configuration, such as MySQL support, LDAP, FTP, and so on.

  19. Recompile PHP:

    sudo make
  20. Install PHP (overwriting any other existing version):

    sudo make install
  21. Restart your web server.

To check if the configuration went smoothly, read the section Testing PHP 4.3 Servers.