Accessibility

Table of Contents

Configuring and Testing PHP Servers for XSL Support

Configuring PHP 4.2 Servers

If you're using PHP 4.2.x, I advise you to upgrade to the latest PHP version for the following reasons:

  • XML and XSL libraries for PHP 4.2 are deprecated and never really reached a truly stable state.
  • Support for XML and XSL has been rewritten from scratch in PHP 5 to offer greater speed, improved memory management, and compliance to W3C standards. You can read more about the XML improvements in PHP 5 in Christian Stoker's article.
  • PHP 5 offers more XML support by default and is a lot easier to configure.

If, however, you are restricted to using PHP 4.2.x as your application server, you must have the following libraries for performing XSL server-side development:

  • Expat
  • iconv
  • Sablotron

Expat is an open-source XML parser. It must be installed prior to Sablotron, as it is required by this library. To learn more about Expat, visit the SourceForge website. Sablotron is an open-source XSLT processor. You can find out more about Sablotron from the Ginger Alliance website. To install these libraries on your server, follow the instructions corresponding to your operating system. It is likely that Expat is already built-in into your PHP or Apache installation.

Configuring PHP 4.2 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 installation steps, check if the required libraries are not already installed on your server by loading the PHP test page in your browser.

  • If Expat is already enabled, you can skip steps 1-3.
  • If both Expat and Sablotron are installed, but XSL support is not enabled, you can skip steps 1-7.
  • If both Expat and Sablotron are installed, and XSL support is enabled, you can skip this section altogether. Your server is already configured for server-side development using XML data.
  1. Download the latest version of Expat for Linux from the SourceForge.net website. The file you're looking for is named expat_win32bin.exe.
  2. Run the downloaded file to install Expat to a folder of your choice on the server.
  3. Locate the expat.dll file in the libs subdirectory of the Expat installation, and copy it to the system32 subdirectory of your Windows installation (usually, C:\Windows\system32\).
  4. Copy the iconv.dll file from the dlls folder of your PHP installation to the system32 subdirectory of your Windows installation. This is a character set conversion library required by Sablotron.
  5. Download Sablotron 0.90 from the Ginger Alliance website. Look for the Windows binary release.
  6. Extract the ZIP file contents to a folder of your choice on your computer. This creates a folder called Sablot-0.90.
  7. Locate the sablot.dll file in the bin subdirectory of your Sablotron installation and copy it to the system32 subdirectory of your Windows installation (usually located at C:\Windows\system32\).
  8. 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 3. Locating your php.ini file

    Figure 3. Locating your php.ini file

  9. 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 that this line is uncommented. For instance, if your PHP installation is located in C:\PHP, the line should be as follows:

    extension_dir = C:\PHP\extensions
  10. Search for the following line in the php.ini file:

    extension=php_xslt.dll

    If this line is missing, locate the Windows Extensions section of the php.ini file and copy it there. If this line is commented, that is, it starts with the semicolon (;) character, uncomment it by deleting the semicolon to enable XSLT support.

  11. Save the php.ini file.
  12. Restart your web server.

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

Configuring PHP 4.2 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 Expat is already enabled, you can skip steps 1-3.
  • If both Expat and Sablotron are installed, but XSL support is not enabled, you can skip steps 1-6.
  • If both Expat and Sablotron are installed, and XSL support is 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 Expat for Linux from the SourceForge.net website. The source file you're looking for is called expat-1.95.8.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 version at the time of writing this article. Please 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 expat-1.95.8.tar.gz

    Unix creates a directory called expat-1.95.8, which contains the files for compiling and installing Expat.

  3. To compile and install Expat, you need root privileges (you may have to log on again using the root user).
  4. Go to the expat-1.95.8 directory and run the following commands at the command prompt, in the given order:

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

    Expat is now installed on your server.

  5. Download Sablotron 0.90 from the Ginger Alliance website. The source file you're looking for is called Sablot-0.90.tar.tar.

    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. Please make sure you use the version number you have in the next instructions.

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

    tar xzvf Sablot-0.90.tar.tar
    

    Linux creates a directory called Sablot-1.0.2, which contains the files for installing and compiling Sablotron.

  7. Go to the Sablot-0.90 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
    make 
    make install

    Sablotron is now installed on your server.

  8. Recompile PHP with XSLT support. To do that, configure it with the following commands, in this sequence:
    ./configure \
    --prefix=/usr/local/php \ 
    --with-config-file-path=/usr/local/php \ 
    --with-apxs=/usr/sbin/apxs \ 
    --enable-xslt \ 
    --with-xslt-sablot=/usr
    

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

    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. Reinstall PHP:

    make install
  11. Restart your web server.

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

Configuring PHP 4.2 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.

  • If Expat is already enabled, you can skip steps 1-6.
  • If both Expat and Sablotron are installed, but XSL support is not enabled, you can skip steps 1-13.
  • If both Expat and Sablotron are installed, and XSL support is 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 the Expat source code package from the SourceForge.net website. The file you need is expat-1.95.8.tar.gz (the latest available version as of writing this article).
  2. Extract the library to a folder of your choice, using StuffIt Expander, or the tar command-line utility:

    tar xzvf expat-1.95.8.tar.gz
  3. Open a Terminal window and navigate to the created folder (usually Expat-1.95.8).
  4. Configure the Expat library for use with your system, by executing the following command:
    ./configure –with-prefix=/usr
  5. Compile the library:

    sudo make
  6. To install the library, you must run the following command:
    sudo make install

    The Expat library should be correctly installed.

  7. Download Sablotron 0.90 from the Ginger Alliance website and save the tar.gz file to your local drive.
  8. Extract the Sablotron library to a folder of choice, using StuffIt Expander, or the tar command-line utility:

     tar xzvf Sablot-0.90.tar.gz
  9. Open a Terminal window and navigate to the created folder (usually Sablot-0.90).
  10. Run the configuration scripts for your system, by executing the following command:

    ./configure –with-prefix=/usr
  11. Compile the library:

    sudo make
  12. Execute the following command to install the library:

    sudo make install
  13. Configure PHP for XSLT support. To do that, execute the following commands in this sequence:

    ./configure --enable-xslt --with-xslt-sablot --with apxs

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

  14. Recompile PHP:

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

    sudo make install
  16. Restart your web server.

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