2.3. Installing PHP

Although PHP runs on many platforms, we describe installing it on Unix, Linux, Mac, and Windows, which represent the majority of Web sites on the Internet. PHP runs with several Web servers, but these instructions focus mainly on Apache and Internet Information Servers (IIS) because together they power almost 90 percent of the Web sites on the Internet. If you need instructions for other operating systems or Web servers, see the PHP Web site, at www.php.net.

NOTE

This chapter provides installation instructions for PHP 5 and 6. If you're installing an earlier version, there are some small differences, so read the install.txt file provided with the PHP distribution.

2.3.1. Installing on Unix and Linux

You can install PHP as an Apache module or as a standalone interpreter. If you're using PHP as a scripting language in Web pages to interact with a database, install PHP as an Apache module. PHP is faster and more secure as a module. We don't discuss PHP as a standalone interpreter in this book.

NOTE

We provide step-by-step instructions in the next few sections for compiling and installing PHP on Linux and Unix. Read all the way through the steps before you begin the installation procedure.

2.3.1.1. Before installing

Before beginning to install PHP, check the following:

  • The Apache module mod_so is installed. It usually is. To display a list of all the modules, type the following at the command line:

    httpd -l

    You might have to be in the directory where httpd

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.