GuidesPHP on Apache: The Definitive Installation Guide Page 3

PHP on Apache: The Definitive Installation Guide Page 3




This will extract the latest versions of everything into the tree starting
at ./php/php3/. The command will display lots of information about
what it’s doing, which can be ignored (except for error messages, of course!).
In order to keep in sync with the latest changes being made to the master
repository, just repeat the last two commands every few days.

Since this method involves grabbing the sources themselves rather than a
prepared package, take at least this one extra step before you build: run
autoconf in order to generate the
./php/php3/configure script. This is simple:

    % cd ./php/php3/
    % ./buildconf
    % autoconf

and you’re ready to build.

To follow this path, subscribe to the php-dev mailing list to
keep up to date with changes (like the addition of the buildconf
step above, which is quite recent—and necessary; PHP won’t build without
it!). Find out more about the PHP mailing lists at
http://www.php.net/support.php3.

PHP Extensions

The PHP package is just brimful of capabilities that you can enable if you
have the appropriate extra pieces installed on your system. For instance, one
of PHP’s strong points is its simple and easy interface to numerous different
database system such as Oracle, MySQL, mSQL, DB2, and so on.

You enable these extensions by letting the ./php/php3/configure
script know about them when you invoke it. For example, if you want to be able
to use MySQL and XML within your PHP scripts (or PHP pages), you might invoke
it as

    % ./configure --with-mysql --with-xml

To see a list of the extensions that PHP can support, invoke the script as

    % ./configure --help

Building PHP for CGI Use

Like Perl, PHP can be used in standalone scripts as well as embedded in Web
pages. Unfortunately, to do both you will need to build it twice: once for each
type of use. (Version 4 of PHP supposedly allows a single build to provide both
the standalone script engine and the Apache module.)

Building the PHP script interpreter is very simple:

    % cd ./php/php3/
    % rm -f config.status config.cache
    % make clean
    % ./configure --enable-discard-path other-options
    % make
    % make install

(Performing the make install step requires write
access
to the /usr/local/bin directory, so you may need to
execute it as root.)

The --enable-discard-path switch on the
./configure invocation is necessary to use PHP scripts as CGI
scripts under a Web server, such as in the cgi-bin directory. To
just invoke PHP scripts directly from shell command lines, you can omit it. Of
course, it does no harm to include it, so you might as well.

Building PHP as an Apache Module

To use embedded PHP code in Web pages, build it in one of two different
ways, depending upon whether it is to be loaded dynamically or built
permanently into the Apache server. The only difference between the interpreter
and dynamic module builds is the configure command; the sequence
for building it as a static module is considerably more complex.

In order to allow Apache to recognise PHP-enabled HTML files as being grist
for mod_php's mill requires a line like the following in the
/usr/local/web/apache/conf/httpd.conf file:

   AddType application/x-httpd-php3 .php3

Then the Web server will know to invoke the PHP module to process the file.

Linking it Statically

Latest Posts

Related Stories