Compiling and Installing the Software

I l @ ve RuBoard

After you've successfully downloaded all the sources, the next step is to configure, compile, and install the different packages. The next sections show you how.

Step 1Unpacking the Sources

Unpack all the sources to a temporary area on your system (I'll be using /tmp/sources/ ).

 $ cd /tmp/sources/  $ tar -xzvf libxml2-2.4.9.tar.gz  $ tar -xzvf expat-1.95.2.tar.gz  $ tar -xzvf Sablot-0.71.tar.gz  $ tar -xzvf zlib-1.1.3.tar.gz  $ tar -xzvf apache_1.3.20.tar.gz  $ tar -xzvf php-4.1.1.tar.gz 

You should end up with a directory structure that looks something like this:

 $ ls -l /tmp/sources/  drwxrwxrwx    5 root     root         4096 Feb  4 15:51 Sablot-0.71  drwxr-xr-x    8 root     root         4096 Feb  4 16:22 apache_1.3.20  drwxr-xr-x    7 root     root         4096 Feb  4 15:26 expat-1.95.2  drwxrwxrwx   11 root     root         4096 Feb  4 15:13 libxml2-2.4.9  drwxrwxr-x   16 root     root         4096 Feb  4 16:13 php-4.1.1  drwxr-xr-x    7 root     root         4096 Feb  4 15:15 zlib-1.1.3 

Step 2Adding the External Libraries

Next, configure, build, and install the external libraries required by PHP. Here's how:

  1. Configure, build, and install expat.

     $ cd expat-1.95.2  $ ./configure  $ make  $ make install 

    Unless you specified a different directory, the expat library should get installed to /usr/local/lib/ . ( You can specify a different directory by adding the --prefix to the configure script.)

    Run the library linker ldconfig to tell the system about the newly installed library.

     $ /sbin/ldconfig 

    The Root of All Errors . . .

    You probably do not require superuser, or root , privileges while configuring and building these libraries. However, you do require superuser privileges when running the final make install and ldconfig commands because these commands access restricted areas of the system.

  2. Configure, build, and install zlib.

     $ cd ../zlib-1.1.3  $ ./configure  $ make  $ make install 

    Unless you specified a different directory, the zlib library should get installed to /usr/local/lib/ . (You can specify a different directory by adding the --prefix to the configure script.)

    Run the library linker ldconfig to tell the system about the newly installed library.

     $ /sbin/ldconfig 
  3. Configure, build, and install libxml.

     $ cd ../libxml2-2.4.9  $ ./configure  $ make  $ make install 

    Unless you specified a different directory, the libxml library should get installed to /usr/local/lib/ . (You can specify a different directory by adding the --prefix to the configure script.)

    Run the library linker ldconfig to tell the system about the newly installed library.

     $ /sbin/ldconfig 
  4. Configure, build, and install Sablotron.

     $ cd ../Sablot-0.71  $ ./configure  $ make  $ make install 

    Unless you specified a different directory, the Sablotron library should get installed to /usr/local/lib . (You can specify a different directory by adding the --prefix to the configure script.)

    Run the library linker ldconfig to tell the system about the newly installed library.

     $ /sbin/ldconfig 

Looking in the Wrong Places

Make sure that the location these libraries get installed to ( /usr/local/lib/ , in this case) is specified in the system's library configuration file (usually /etc/ld.so.conf ), or else the final call to ldconfig will have no effect whatsoever.

Step 3Adding PHP

After all the external libraries have been built and installed, it's time to configure, build, and install PHP. Here's how (do one of the following):

  • If you want to compile PHP as a module into the Apache web server, you need to first configure it appropriately. To do this, first change into the Apache directory and run Apache's configuration script.

     $ cd ../apache_1.3.20  $ ./configure 

    This is a necessary precondition to compiling PHP as an Apache module because it tells PHP where to find Apache's header files.

    Now, move back to the PHP directory, and configure PHP with support for all required XML extensions.

     $ cd ../php-4.1.1  $ ./configure --with-apache=../apache_1.3.20 --enable-track-vars--with-mysql --with-dom graphics/ccc.gif --enable-sockets --enable-wddx --with-xmlrpc--enable-xslt --with-xslt-sablot graphics/ccc.gif --with-zlib-dir=/usr/local/lib/  $ make  $ make install 

    You should now have a PHP module suitable for use with the Apache web server. This module should have been copied automatically into the Apache source tree.

    The MySQL Files

    PHP 4.x comes with built-in support for MySQL (note the additional --with-mysql parameter to the PHP configure script). However, if you're compiling PHP as a module for a web server and plan to use other MySQL-based server modules with it, you should not rely on this built-in support, but should instead use your locally installed copy of the MySQL client libraries and header files.

    Note that this appendix does not include any information on configuring or installing MySQL on your system. For more information on this, you should refer to the documentation available at http://www.mysql.com/

  • If you want to compile a standalone PHP binary, you don't need to bring Apache into the picture at all. Simply change into your PHP directory and run the configure script with the following options:

     $ cd ../php-4.1.1  $ ./configure --enable-track-vars --with-mysql --with-dom --enable-sockets--enable-wddx graphics/ccc.gif --with-xmlrpc --enable-xslt --with-xslt-sablot--with-zlib-dir=/usr/local/lib/  $ make  $ make install 

    You should now have a PHP binary installed to /usr/local/bin/ , which can be used to execute any PHP script from the command line. Skip the following steps and proceed directly to the section titled "Testing the Software" to verify that your PHP build has support for all the required extensions.

Step 4Adding Apache

If you decided to compile PHP as an Apache module, the next step is to compile and install Apache. Move back into the Apache directory, configure Apache to use the PHP module created in the first choice of "Step 3Adding PHP," and build and install it.

 $ cd ../apache_1.3.20  $ ./configure --prefix=/usr/local/apache--activate-module=src/modules/php4/libphp4.a  $ make  $ make install 

When All Else Fails, RTFM!

If you have trouble installing PHP as an Apache module, you should check the "Verbose Install" section of PHP's INSTALL file.

Step 5Configuring Apache to Work with PHP

After Apache has been installed, open up Apache's configuration file, httpd.conf , in your favorite text editor, and add the following lines to it so that Apache knows how to handle files with the .php extension:

 AddType application/x-httpd-php .php  AddType application/x-httpd-php-source .phps  DirectoryIndex index.php index.html 

Step 6Starting Apache

Start the Apache web server via the included apachectl script.

 $ /usr/local/apache/bin/apachectl start 

Time Flies When You're Having Fun

You should be aware that the process of recompiling PHP with XML support is fairly time-consuming . Expect to spend between 30 to 60 minutes compiling and installing the various packages to your system.

Table A.1 shows an estimate of how long it takes to compile each package on different systems.

Table A.1. A Comparison of the Time Taken to Recompile PHP with XML Support on Different Systems

Package

Estimated Time on a P-200 with 64MB RAM

Estimated Time on a Duron-800 with 128MB RAM

expat

3 minutes

1 minute

zlib

3 minutes

30 seconds

libxml

9 minutes

2 minutes

Sablotron

12 minutes

3 minutes

PHP

20 minutes

7 minutes

Apache

5 minutes

3 minutes

Total

52 minutes

16 1/2 minutes

A Note for Windows Users

The preceding sections document the process of recompiling PHP with XML support on Linux and other UNIX variants. If you're using Windows, most of what you've just read is irrelevant to you. This is because Windows users get a pre-built PHP binary, which already includes support for most common extensions, and they need only to activate these extensions via the Windows php.ini configuration file.

The extensions that need to be activated in the php.ini configuration file (look in the section titled "Dynamic Extensions") are the following:

  • php_domxml.dll

  • php_xslt.dll

  • php_sockets.dll

You can activate these extensions by removing the semicolon (;) at the beginning of the corresponding line in php.ini . Remember to restart the web server for your changes to take effect.

Note that the Windows versions of PHP 4.1.1 and 4.2.0 include built-in support for WDDX, but no support for the XML-RPC extension.

For detailed instructions on getting PHP and Apache to talk nicely to each other on the Windows platform, refer to the installation instructions that ship with the Windows version of PHP, or visit the web page at http://www.php.net/manual/en/install.windows.php.

I l @ ve RuBoard


XML and PHP
XML and PHP
ISBN: 0735712271
EAN: 2147483647
Year: 2002
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net