Chapter 2. Installing PHP

Even if you intend to use a remote web server for your site, where PHP is already installed, it is still beneficial to be able to install PHP on your own machine so that you can test your pages more easily.

Installing PHP yourself opens up many possibilities: you get to choose exactly which extensions are available, which options are enabled, and the filesystem layout that you want. Of course, if you intend to upload your scripts to a different server at the end of the process, you should be careful to mimic the remote configuration on your local machine.

This chapter goes through a full install of PHP on Windows and Unix, installing extensions, and also configuring settings in the php.ini configuration file.

Installing on Windows

For installation on Windows, you need to download the Windows binary zip package from http://www.php.net/downloads.php. This contains the main PHP executables and DLLs, plus many extensions pre-compiled and ready to use.

When you extract the zip file, it should create a folder similar in name to php-5.0.4-Win32. I suggest you rename it to "php" and move it to the root of your hard drive, giving c:\php.

Browse to the new c:\php directory, and you'll see a number of files. Copy the php5ts.dll file into your c:\windows\system32 directory (note: this may be c:\winnt on some versions of Windows), then copy the php.ini-recommended file into your c:\windows directory, renaming it to php.ini. This is the file where you will be setting all ...

Get PHP in a Nutshell 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.