Obtaining PHP

At the present time, two versions of PHP are available: PHP 4 and PHP 5. When PHP 6 is released, three versions of PHP may be available for a period of time. If you are installing PHP for the first time and creating your first Web site, you should download PHP 5, or PHP 6 if it is available at the time you are installing PHP. You should only install an older version of PHP if you need to maintain or modify an existing Web site, with existing code. Code that is written for one version of PHP may need to be modified to run on another version of PHP. If you have a lot of code, you may want to update the code over a period of time.

Downloading from the PHP web site
Obtaining PHP for Windows
Obtaining PHP for Linux
Obtaining PHP for Mac
Obtaining All-in-one Installation Kits
Verifying a downloaded file

Downloading from the PHP Web Site

PHP for all operating systems is available on the PHP Web site at www.php.net. You can download source code to compile on your operating system. Compiling and installing source code is not difficult on Linux and Mac, but requires expert knowledge and software on Windows.

Binary files--compiled, ready-to-run files that just need to be copied to the correct location--are only available for Windows. Binary files for Linux and Mac may be obtained from other Web locations, but not from the PHP Web site.

Obtaining PHP for Windows

You can easily install PHP from binary files that you can download from the PHP Web site at www.php.net. You can download a zip file that contains all the necessary files or an installer that you can run to install all the PHP files. The PHP documentation recommends that you install PHP from the zip file for better understanding of the installation and easier addition of extensions later. The directions in this chapter provide instructions for installing PHP from the zip file.

While Windows users can compile and install PHP from source code, also available from the PHP Web site, it is difficult and should only be attempted by advanced users. It requires advanced knowledge and special software.

To download the Windows zip file:

  1. Go to www.php.net/downloads.php
  2. Download the zip package for the most recent version of PHP.

Obtaining PHP for Linux

Most recent versions of Linux include PHP. If you need to install PHP or upgrade to a more recent version, most Linux distributions provide software on their Web site that you can download and install on your specific Linux system. In addition, most Linux systems provide software specifically for downloading and installing software. For instance, Fedora provides the yum utility that downloads and installs software from the Fedora Web site. See the documentation for your Linux distribution for information on how to download and install software on your Linux distribution.

In some cases, you may need to install PHP manually. The software provided by the Web site may not be the most recent or may not be configured to your needs. To install manually, you need to download the source code from the PHP Web site at www.php.net.

You can easily compile and install PHP from the source code. This process is not as technical and daunting as it sounds. Instructions for installing PHP from source code on Linux are provided in the section Installing PHP.

Obtaining PHP for Mac

PHP comes already installed on most recent versions of Mac OS X. If you need to install PHP, because it's not installed or an older version is installed, the easiest way is to install from a binary file. The PHP Web site doesn't provide a binary, but binaries are provided for some versions of OS X at www.entropy.ch/software/macosx/php/. The information needed to download and install the binary is provided at this Web site. Check the support and extensions provided in the binary to ensure that you have the features you need.

If the binary does not provide the features or extensions you need, you can download the source files from the PHP Web site to compile and install on your Mac. Instructions for installing PHP from the source code are provided in the section Installing PHP.

Obtaining All-in-one Installation Kits

You can obtain some kits that contain and install PHP, MySQL, and Apache in one procedure. These kits can greatly simplify the installation process. However, the software provided may not include the features and extensions that you need.

XAMPP is a popular all-in-one installation kit that contains Apache, PHP, and MySQL. It also installs phpMyAdmin, a utility for managing your MySQL databases. XAMPP has stable versions available for Windows and for several versions of Linux. In addition, versions of XAMPP are available for Mac and Solaris, but these versions are currently new and less well tested and developed. XAMPP is available at www.apachefriends.org/en/xampp.html.

WAMP5 is a popular installation kit for Windows that provides recent versions of Apache 2.2, PHP 5, and MySQL 5. It also installs phpMyAdmin, a utility for managing your MySQL databases. The WAMP5 Web site states that it is compatible with Vista. WAMP5 does not run on Windows 98/ME. WAMP5 is available at www.en.wampserver.com/.

Verifying a Downloaded File

The PHP Web site provides methods to verify the software after you download it, as a security precaution to make sure that the file has not been altered by bad guys. You can verify using either the MD5 method or the PGP method. The MD5 method is simpler and is described in this section.

Below the file you downloaded, on the download Web page, a long string, called a signature, is displayed, similar to the following:

   MD5: 6112f6a730c680a4048dbab40e4107b3 

The downloaded PHP file needs to provide the same MD5 signature shown on the download page. You use software on your computer to check the md5 signature of the downloaded file. Your Linux or Mac system includes software to check the MD5 signature. On Windows, you may need to download and install MD5 software. You can find software that checks MD5 signatures at www.fourmilab.ch/md5/.

To check the MD5 signature of the downloaded file, at a command line prompt, such as in a command prompt window in Windows, in the directory where the downloaded file resides, type:

   md5 filename

Use the name of the file that you downloaded, such as md5 php-5.2.1-Win32.zip. In Windows, you may need to copy the downloaded file to the directory where the MD5 software (such as, md5.exe) is installed, CD to this directory, and then type the above command.

A signature displays. The signature here should be the same signature displayed under the filename on the download page of the PHP Web site.

A simple, open-source (free) Windows program with a Graphical Interface that allows you to check MD5 signatures by clicking buttons and dragging filenames, rather than by typing commands in a Command Prompt window, can be obtained at www.nullriver.com/index/products/winmd5sum