Section 2.1. Installing on Windows


2.1. 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 your PHP configuration options.

Your basic Windows PHP installation is now complete. If you want to set up PHP to use a web server, read the appropriate section below. You may also want to enable some extensionsthat, too, is covered in subsequent pages.

2.1.1. Installing Apache

The first step to install Apache is to download the Windows installer from http://httpd.apache.org. This is packaged using the Microsoft Installer system (MSI), so you may be prompted to install the MSI software if you have an older release of Windows.

As Apache is packaged into a friendly installer, you need only answer a few basic questions and click "Next" until you have completed the installation. The default installation is placed into c:\program files\apache group\apache2. Inside there is the conf directory, which contains Apache's configuration files.

Inside the conf directory, you'll find the httpd.conf file. This contains most of the configuration settings for Apache, and you need to edit this in order to enable PHP. Any line that starts with a # symbol is a comment, and may provide further documentation to guide you in your edits. First, search for the string "LoadModule." There should be a collection of these LoadModule lines in there already, so scroll to the bottom and add this new one:

     LoadModule php5_module c:/php/php5apache2.dll 

If your PHP installation is in a place other than c:\php, you will need to enter something different. Note, though, that all backslashes should be converted to forward slashes to avoid problems.

The next step is to search for the string AddType, and again you should see one or two lines of this type already in there. Underneath them, add this line:

     AddType application/x-httpd-php .php 

That associates scripts with the extension .php with our PHP module. If you want different script extensions, here is the place to set that up.

That completes the basic configuration. If you click Start, then Run, and run the command services.msc, you should see the Windows Services list appear. Look for Apache2, then click the button with the Stop and Play symbols on it to restart the servicethis should enable PHP.

Once Apache has been restarted, open a web browser and go to http://localhost. You should see the "If you can see this, it means that the installation of the Apache web server software on this system was successful" default page on Apache. To test your PHP install, turn to the "Testing Your Configuration" section, later in this chapter, using c:\program files\apache group\apache2\htdocs as the HTML directory.

To change the directory from which Apache should serve web pages, search for the two instances of "C:/Program Files/Apache Group/Apache2/htdocs" in your httpd.conf and replace them with another directory on your system.

2.1.2. Installing Microsoft IIS

Although Apache is the preferred web server platform irrespective of the OS you choose, PHP can also be used with Microsoft Internet Information Services (IIS). This is available on Windows NT, Windows 2000, Windows XP, and Windows Server 2003; however, the client versions (e.g., XP) are limited in their abilities compared to the server versions. These instructions were written for Windows XP, but the instructions should be broadly similar for other versions of Windows and IIS.

To install IIS, go to the Add/Remove Programs dialog in the Control Panel, then select "Add/Remove Windows Components" from the sidebar. After a moment, a list of components will appear, and "Internet Information Service (IIS)" will be one of the options. Check the box next to it, then click Next. You may be asked for your Windows CD, so have it ready.

After installation has finished, open up Internet Explorer and point it at http://localhost; all being well, you should see the "Your Web service is now running" page. Note that you should use Internet Explorer as opposed to other browsersIIS doesn't play well with Firefox or others.

It is highly recommended that you go to the Windows Update site immediately after installing IIS. The version installed from your CD will almost certainly be out of date, so you should download and install the latest patches before proceeding.


To configure IIS to use PHP, you need to bring up the Internet Information Services Management Console snap-in. This is available from Administrative Tools options, which may be in your Start menu or in your Control Panel, depending on your configuration.

The default view shows your computer in the left-hand tree; you need to double-click that to bring up the "Web Sites" branch, then double-click on "Web Sites" to reveal the "Default Web Site" branch. The default web site is configured to serve pages from c:\inetpub\wwwroot, and we're going to configure that to be able to serve PHP scripts too.

Right-click on the "Default Web Site" branch in the left-hand pane, and select Properties. From the dialog that appears, go to the Home Directory tab, and click the Configuration button at the bottom right. This is where you configure the programs that handle scripts on the server, and you'll see things such as ASP already configured.

Click the Add button in the Application Configuration dialog, then click Browse to search for the PHP script handle for IIS. By default, the Open File dialog box that appears is set to "Executable files (*.exe)," but you need to change that to "Dynamic Link libraries (*.dll)." Now browse to where you installed PHP (e.g., c:\php), and select the file php5isapi.dll, and click OK.

Back in the "Add/Edit Application Extension Mapping" dialog, enter .php for the extension, and click OK. Click OK in the Application Configuration dialog, then OK again in the Default Web Site Properties dialog, and you'll be back at the IIS snap-in again.

To test out your configuration, turn to the "Testing Your Configuration" section, later in this chapter, using c:\inetpub\wwwroot as the HTML directory.

To change the directory from which IIS should serve web pages, go back to the Default Web Site Properties dialog, go to the Home Directory tab, and edit the Local Path field to something other than c:\inetpub\wwwroot.

2.1.3. Configuring Extensions

The PHP zip file for Windows comes with a number of extensions compiled for you. To enable them, you need only edit php.ini and remove the comment symbol (a semicolon) from the start of the line. Once you have finished your edits, restart your web server to have it reload the modules, and you'll be ready to go.

For example, to enable the Tidy extension, bring up c:\windows\php.ini in Notepad, search for "tidy", and you'll see a line like ";extension=php_tidy.dll." To enable the extension, remove the semicolon from the front (to make the line "extension=php_tidy.dll"), then restart your web server.



PHP in a Nutshell
Ubuntu Unleashed
ISBN: 596100671
EAN: 2147483647
Year: 2003
Pages: 249

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net