The first step to creating your own interactive
web pages is to get access to a web server that runs PHP. In fact,
your Internet Service Provider (ISP) probably supports PHP already.
You can find out by asking your ISP's support staff, or you can
test for PHP yourself in one of two ways.
First, if you can
a command prompt by
connecting to your web server using a Telnet, SSH, or SSH2
application (don't worry if you don't know what these applications
areyou won't need them in this book), you can try typing
at the command line (we'll use a
sign for a
generic command prompt in this book). If you have PHP installed,
you'll see something like this:
PHP 5.0.0 (cli) (built: Jul 13 2004 21:39:58)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.0, Copyright (c) 1998-2004 Zend Technologies
The other way to determine whether you have PHP
installed is by trying out an actual PHP script. To do that, take a
look at the section "Creating Your First PHP Script" in this
chapter. If that script works, you've got PHP installed, and you're
If you want a list of ISPs that already run PHP,
take a look at www.php.net/links.php#
Installing PHP Locally
It's a good idea to install PHP on your own
computer so that you can test your PHP scripts as you develop them.
This way, you won't have to take the time to upload your PHP
scripts to your ISP, check them by downloading them in your
browser, make changes, and then start the whole cycle again. If you
develop your PHP scripts locally, you can get things running a lot
faster, but you'll need to install PHP on your own machine.
Some operating systems, such as Linux and many
versions of Unix, now come with PHP installed by default. In
others, such as Windows and Mac OSX, you'll have to download and
install PHP yourself. The first step is to check if you already
have PHP available locallytry the
command at the
command prompt (for example, in Windows, open a DOS window and type
). If it works, you're all set.
If you don't have PHP already installed, you can
install it yourself. Prebuilt "binary" versions are available for
download and immediate installation for a number of operating
systems: Windows, Mac OSX, Novell NetWare, OS/2, RISC OS, SGI IRIX
6.5.x, and AS/400. You can find the binary installation package for
Windows at http://www.php.net/downloads.php, along with links to
the binaries for the other operating systems mentioned.
Binaries are no longer distributed for Linux and
Unix because PHP is usually pre-installed. If you want, you can
build your own PHP installation from source code. Go to
http://www.php.net/downloads.php to get the source code for
You can find the installation instructions for
PHP in the PHP documentation, which is online at
http://www.php.net/docs.php (you can download the complete PHP
documentation from http://www.php.net/download-docs.php). You can
also find installation instructions in an installation file (named,
for example, install.txt) when you uncompress the PHP download.
Because the instructions change every time PHP changes, and because
there are so many possible variations of operating systems and web
servers, you should read the current installation instructions and
use them. Listing all the instructions here would take 20 pages,
and they'd be obsolete by the time you read them.
Briefly, here's how things might work in Windows
XP (all this can be found in full detail in the downloadable
installation instructions). You first need a web server, such as
the Apache web server or Microsoft's Internet Information Server
(IIS). You can get a Windows installer file for Apache
(apache_2.0.52-win32-x86-no_ssl.msi) at http://httpd.apache.org/
; when you download and double-click this
Apache. Or you can install IIS in Windows XP by
using the Add/Remove Programs icon in the Control Panel, clicking
the Add/Remove Windows Components button, and then selecting
PHP can be installed in two different ways for
Windows, and you can download what you need for both
http://www.php.net/downloads.php. There's a Windows installer
executable file, php-5.0.
-installer.exe, with basic PHP support (which
includes standard PHP but no external extensions). This installer
will automatically configure servers such as IIS, PWS, and Xitami,
and it has instructions for manual configuration of other servers
such as Apache.
The other installation technique uses a .zip
contains the full PHP installation and allows for external
extensions (this option is better if you want to do everything
covered in this book). Download and unzip this file; you'll find
all the installation instructions included. Depending on your
operating system, you typically copy php.exe to the directory from
which you intend to run it, for example.
step is to connect your PHP
installation to your web server. If you've
the PHP .zip
file in Windows XP and you're using Apache, you should edit the
Apache http.conf file, following the directions in the installation
instructions. If you're using IIS, you configure IIS with its
management console (select Start > Settings > Control Panel
> Administrative Tools > Internet Services Manager in Windows
XP), also following the directions in the installation
instructions. For the full details, see the instructions, which
take you through everything step by step.