Actions

Difference between revisions of "Plugins/Artefact/Europass/Configuring and Testing PHP Servers for XSL Support"

From Mahara Wiki

< Plugins‎ | Artefact‎ | Europass
(Created page with "Original article by '''Marius Zaharia''', '''Cristian Ivascu''', available [http://flex.sys-con.com/node/200299?page=0,3 here]. <div id="section_1"> === Configuring PHP 5 Serve…")
 
Line 3: Line 3:
 
<div id="section_1">
 
<div id="section_1">
  
=== Configuring PHP 5 Servers on Windows ===
+
===Configuring PHP 5 Servers on Windows===
  
 
The following instructions assume you have already installed a web server with PHP language support on a computer running Windows. Fortunately, there are a lot of free tools on the Internet that help you install and configure a web server automatically. My personal favorite is WAMP Server, which also sets up a MySQL server, phpMyAdmin and SQLiteManager, in addition to Apache and PHP. For detailed instructions on installing WAMP Server, visit this web page.
 
The following instructions assume you have already installed a web server with PHP language support on a computer running Windows. Fortunately, there are a lot of free tools on the Internet that help you install and configure a web server automatically. My personal favorite is WAMP Server, which also sets up a MySQL server, phpMyAdmin and SQLiteManager, in addition to Apache and PHP. For detailed instructions on installing WAMP Server, visit this web page.
Line 27: Line 27:
 
</div><div id="section_2">
 
</div><div id="section_2">
  
=== Configuring PHP 5 Servers on Linux ===
+
===Configuring PHP 5 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 configuration instructions, check if the required libraries are not already enabled on your server by loading the PHP test page in your browser.
 
The following instructions assume you have already installed a web server with PHP language support on a computer running Linux. Before proceeding with the configuration instructions, check if the required libraries are not already enabled on your server by loading the PHP test page in your browser.
Line 51: Line 51:
 
</div><div id="section_3">
 
</div><div id="section_3">
  
=== Configuring PHP 5 Servers on Mac OS X ===
+
===Configuring PHP 5 Servers on Mac OS X===
  
 
The following instructions assume you have already installed a web server with PHP language support on a computer running MAC OS X. In the default configuration, the Apache web server is installed, but PHP support is disabled. To learn how to enable it, read the article by James Pelow.
 
The following instructions assume you have already installed a web server with PHP language support on a computer running MAC OS X. In the default configuration, the Apache web server is installed, but PHP support is disabled. To learn how to enable it, read the article by James Pelow.
Line 96: Line 96:
 
</div><div id="section_4">
 
</div><div id="section_4">
  
=== Testing PHP 5 Servers ===
+
===Testing PHP 5 Servers===
  
 
The first proof of a successful installation is that your web server doesn't throw any errors after restarting. To check if everything went smoothly, load the PHP test page in your browser. You should see a section similar to the following image ([http://gemsres.com/story/mar06/200299/fig09.gif Figure 4]), if the DOM extension was successfully enabled.
 
The first proof of a successful installation is that your web server doesn't throw any errors after restarting. To check if everything went smoothly, load the PHP test page in your browser. You should see a section similar to the following image ([http://gemsres.com/story/mar06/200299/fig09.gif Figure 4]), if the DOM extension was successfully enabled.

Revision as of 16:38, 11 May 2011

Original article by Marius Zaharia, Cristian Ivascu, available here.

Configuring PHP 5 Servers on Windows

The following instructions assume you have already installed a web server with PHP language support on a computer running Windows. Fortunately, there are a lot of free tools on the Internet that help you install and configure a web server automatically. My personal favorite is WAMP Server, which also sets up a MySQL server, phpMyAdmin and SQLiteManager, in addition to Apache and PHP. For detailed instructions on installing WAMP Server, visit this web page.

Before proceeding with the configuration instructions, check if the required libraries are not already enabled on your server by loading the PHP test page in your browser.

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

  • Locate the php.ini configuration file for your current PHP installation (usually 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:

  • Search the following line:

;extension=php_xsl.dll

  • and uncomment it by removing the ; character.
  • Save the php.ini file.
  • Restart your web server.

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

Configuring PHP 5 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 configuration instructions, check if the required libraries are not already enabled on your server by loading the PHP test page in your browser.

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

Configure PHP with 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-libxml-dir=/usr
  • --with-xsl=/usr 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. 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 the section Testing PHP 5 Servers.

Configuring PHP 5 Servers on Mac OS X

The following instructions assume you have already installed a web server with PHP language support on a computer running MAC OS X. In the default configuration, the Apache web server is installed, but PHP support is disabled. To learn how to enable it, read the article by James Pelow.

Before proceeding with the configuration instructions, check if the required libraries are not already enabled on your server by loading the PHP test page in your browser.

You can also download a package that will install PHP 5.04 (as of writing this article) with default support for XML and XSLT from the entropy.ch website.

  • If libxml2 is already enabled, you can skip steps 1-7.
  • If both libxml2 and libxslt are already installed, but XSLT support is not enabled in your PHP installation, you can skip steps 1-12.
  • Download the latest source code version of the libxml2 library from the Gnome Project website.
  • Extract the library to a folder of choice, using either StuffIt Expander, or the tar command line utility:
  • tar xzvf libxml2-2.6.20.tar.gz
  • Open a Terminal window and navigate to the created folder.
  • Configure the libxml2 library with the following command:
  • ./configure ­with-prefix=/usr/local
  • Compile the library:
  • make
  • Install the libxml library on your server (you need to know the root password):
  • sudo make install
  • Download the latest source code version of the libxslt library from this website.
  • Extract the library to a folder of your choice, using either StuffIt Expander, or the tar command line utility:
  • tar xfz libxslt-1.1.14.tar.gz
  • Open a Terminal window and navigate to the created folder.
  • Configure the libxslt library, by issuing the following command:
  • ./configure --with-prefix=/usr/local \
  • --with-libxml-prefix=/usr/local /
  • --with-libxml-include-prefix=/usr/local/include \
  • --with-libxml-lib-prefix=/usr/local/lib
  • Compile the libxslt library:
  • make
  • Install the libxslt library on the server (you will need the root password):
  • sudo make install
  • You need to recompile PHP to enable XML and XSL support. Configure PHP with at least the following flags:
  • ./configure --with-xml ­with-zlib ­with-xslt 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 forth.
  • Compile PHP:
  • sudo make
  • Install the new PHP version. It will overwrite any previous version.
  • sudo make install
  • Restart your web server.

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

Testing PHP 5 Servers

The first proof of a successful installation is that your web server doesn't throw any errors after restarting. To check if everything went smoothly, load the PHP test page in your browser. You should see a section similar to the following image (Figure 4), if the DOM extension was successfully enabled.

If XSL support was successfully enabled, too, you should also see a section similar to this one:

Check if these settings are present and enabled:

  • DOM/XML.
  • libXML.
  • XSL.
  • libxslt.

For libxml and libxslt, only the version number may be listed (instead of the enabled/disabled status) ­ this indicates they are present on your server.

Congratulations! Your server is now prepared for server-side development using XML and XSL.