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:
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.
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:
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
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
Search for the following line:
;extension=php_domxml.dll
and uncomment it by removing the semicolon (;) character, to activate DOM XML.
To check if the configuration went smoothly, read Testing PHP 4.3 Servers.
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.
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.
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.
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.
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.
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.
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.
./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.
Compile PHP:
make
Install PHP:
make install
Restart your web server.
To check if the configuration went smoothly, read Testing PHP 4.3 Servers.
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.
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.
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
Compile the library, using the following command:
sudo make
Install the zlib library:
sudo make install
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
Configure the libxml library with the command:
./configure –with-prefix=/usr
Compile the library for your system by running the command:
sudo make
Install the library:
sudo make install
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
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
Compile the library for your system, by running the following command:
sudo make
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.
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.
Recompile PHP:
sudo make
Install PHP (overwriting any other existing version):
sudo make install
To check if the configuration went smoothly, read the section Testing PHP 4.3 Servers.