Datasheet

P1: KTX
WY027-01 WY027-Mercer WY027-v2.cls June 5, 2004 0:44
Getting Up and Running
PHP5 can be installed on a great variety of Web server/operating system combinations, including
under Apache on Windows. The two systems were using are the easiest to get working. If neither of
them suits you, of course you can install whatever other conguration you wantyou should still
be able to run all of the examples in the book. Refer to the PHP5 manual for more general installation
instructions.
Running PHP5
One of the basic choices to make when installing PHP5 with your Web server is whether to run it as a CGI
binary or as a separate static or dynamic module. CGI (Common Gateway Interface) is a very useful way
to run interpreters such as PHP5. Because of security risks (see the Running as a CGIsection later in this
chapter for more information), compiling PHP5 as a static or dynamic module is recommended under
most circumstances. Our installations (on Linux and on Windows) load PHP as a separate SAPI (Server
Application Programming Interface) module. On Windows, the ISAPI lter was used to run PHP as a
SAPI module.
Although it is most common to run PHP in conjunction with a Web server, so that Web pages with a le
extension such as .php are processed through the PHP interpreter before the nished page is sent back to
the browser, there is also a command line utility that enables you to run PHP code from the command
line. It is present from any of the installation types we demonstrate. You can nd plenty of documentation
about it on the PHP site (www.php.net).
Creating and running PHP Web applications in a satisfactory way implies that you are running (or have
access to) a Web server upon which PHP is (or can be) installed, and that the installation has been tested
and runs properly. It also implies that PHP has been (or can be) congured to support the needs of your
PHP programs. There are a couple scenarios under which these requirements can be achieved:
You are running a desktop or server machine, operating system, and Web server compatible with
PHP, and PHP has been installed and congured.
You are running a desktop or server machine connected to the Internet, with access to a Web
hosting account supported by a Web server with which PHP has been installed and congured.
The vast majority of desktop machines run Windows 98, NT, 2000, 2003, and XP. In many cases you can
get a free copy of Personal Web Server (PWS) and install it on a machine running one of these operating
systems. PHP is compatible with PWS, so you can install and congure PHP on desktop machines
running basic operating systems such as Windows 98. Server operating systems such as Windows NT,
2000, and 200, come with Internet Information Server (IIS). PHP is compatible with IIS, and you can install
and congure PHP on these machines. Our Windows 2000 installation of PHP5 uses IIS as a Web server.
The majority of Web-hosting computers run some version of Linux, such as Debian, RedHat, FreeBSD,
and so on. The Web server of choice for these machines is Apache. PHP is compatible with Linux and
Apache, and you can install and congure PHP on these systems, but if you are not in charge of the
Web-hosting computer (and many times you wont be) youll probably have little control over the
installation and conguration. If you nd yourself in this position (for example, if youve been hired to
work on an existing Web site running on someone elses server), you can simply verify the operating
system, Web server software, and PHP version so you can cope with whatever youve have to work with
as you develop your PHP programs.
5