Pages

Mar 14, 2010

Installing PHP (Part 2)


Where to Find PHP and More

You can find PHP4 at . PHP4 is open source software, which
means that you won't need your credit card handy when you download it.
The PHP WebSite is an excellent resource for PHP coders. The entire manual can be
read online at , complete with helpful annotations
from other PHP coders. You can also download the manual in several formats.

Installing PHP4 for Linux and Apache


In this section, we will look at one way of installing PHP4 with Apache on Linux. The
process is more or less the same for any UNIX operating system. You might be able
to find prebuilt versions of PHP for your system, which are simple to install.
Compiling PHP, though, gives you greater control over the features built in to your
binary.
Before you install you should make sure that you are logged into your system as the
root user. If you are not allowed access to your system's root account, you may
need to ask your system administrator to install PHP for you.
There are two ways of compiling an Apache PHP module. You can either recompile
Apache, statically linking PHP into it, or you can compile PHP as a Dynamic Shared
Object (DSO). If your version of Apache was compiled with DSO support, it will be
capable of supporting new modules without the need for recompiling the server.

This method is the easiest way to get PHP up and running, and it is the one we will
look at in this section.
In order to test that Apache supports DSOs you should launch the Apache binary
(httpd) with the -l argument.
/www/bin/httpd -l
You should see a list of modules. If you see
mod_so.c
among them, you should be able to proceed; otherwise, you may need to recompile
Apache. The Apache distribution contains full instructions for this.
If you have not already done so, you will need to download the latest distribution of
PHP4. Your distribution will be archived as a tar file and compressed with gzip, so
you will need to unpack it:
tar -xvzf php-4.0.tar.gz
After your distribution is unpacked, you should move to the PHP4 distribution
directory:
cd ../php-4.0
Within your distribution directory you will find a script called configure. This accepts
arguments that will control the features that PHP will support. For this example, we
will include some useful command line arguments, although you might want to
specify arguments of your own. We will discuss some of the configure options
available to you later in the hour.
./configure --enable-track-vars \
--with-gd \
--with-mysql \
--with-apxs=/www/bin/apxs
The path you assign to the --with-apxs argument is likely to be different on your
system. It is possible that you will find apxs in the same directory as your Apache
executable.
After the configure script has run, you can run the make program. You will need a C
compiler on your system to run this command successfully.
make

make install
These commands should end the process of PHP4 compilation and installation. You should now be able to configure and run Apache.

0 comments: