4/28/09

Installing PHP

The next step is to install PHP. At the time of this writing, PHP 5.0 has just been released, with numerous improvements over the previous version; however, PHP 4.3 has become well-established as the version of choice due to its track record of stability and performance. The procedures for installing these two versions are nearly identical. Although I’ll focus primarily on installing PHP 5.0 in these pages, I’ll note any significant differences if you happen to be working with PHP 4.3. All of the code in this book will work with both versions of PHP. Download PHP for free from http://www.php.net/downloads.php. You’ll want the PHP 5.x zip package under Windows Binaries; avoid the installer version if you can. PHP was designed to run as a plug-in for existing Web server software such as Internet Information Services, Apache, Sambar or OmniHTTPD. To test dynamic Web pages with PHP, you’ll need to equip your own computer with Web server software, so that PHP has something to plug into.
if you have Windows 2000, XP Professional 3 , or Server 2003, then install IIS (if it’s not already on your system): open Control Panel > Add/Remove Programs > Add/Remove Windows Components, and select Internet Information Services (IIS) from the list of components. If you’re not lucky enough to have IIS at your dis-posal, 4 you can use a free, third-party Web server like Apache instead. I’ll give instructions for both options in detail.

First, whether or not you have IIS, complete these steps:
  1. Unzip the file you downloaded from the PHP Website into a directory of your choice. I recommend C:\PHP and will refer to this directory from this point onward, but feel free to choose another directory if you like.
  2. Find the file called php5ts.dll in the PHP folder and copy it to the system32 subfolder of your Windows folder (e.g. C:\WINDOWS\system32).
  3. Find the file called php.ini-dist in the PHP folder and copy it to your Windows folder. Once it’s there, rename it php.ini.
  4. Open the php.ini file in your favorite text editor (use WordPad if Notepad doesn’t display the file properly). It’s a large file with a lot of confusing op-tions, but look for a line that begins with extension_dir, and set it so that it points to the ext subfolder of your PHP folder: extension_dir = "C:\PHP\ext" A little further down, you’ll see a bunch of lines beginning with ;extension=.
    These are optional extensions, disabled by default. We want to enable the MySQL extension so that PHP can communicate with MySQL. To do this, remove the semicolon from the start of the php_mysql.dll line: extension=php_mysql.dll Even further down, look for a line that starts with session.save_path and set it to your Windows TEMP folder: session.save_path = "C:\WINDOWS\Temp" Save the changes you made and close your text editor.

No comments:

Post a Comment