Installing and Configuring PHP on Windows Tutorial

Installing PHP on Windows Tutorial

Downloading and Installing PHP 5 on Windows


The first thing you need to do is download the windows binary zip files that will work on apache, you can download these files from http://www.php.net/downloads.php under the section windows binaries.



You should grab the newest 5.x.x Windows Binaries zip package that will work on apache.  In our case we will select package PHP 5.2.11 and we will download from the closest mirror site based in Ireland.



 

Next =>

  • Unzip php to the directory:
    C:\php\
  • Rename C:\php\php.ini-dist it to php.ini
  • Edit your php.ini

Open php.ini in a text editor and scroll down about halfway through the file and look for doc_root then change it to point to whatever your IIS or Apache DocumentRoot is set to. In my case: doc_root = "C:\inetpub\public_html"

Scroll down about 7 more lines and change the extension_dir from extension_dir = "./" to the location of the ext directory after you unzipped PHP. in my case: extension_dir = "C:\php\ext"

(Lowercase php)

Uncomment the extensions you want to use.
It’s important to be sure that php_mysql.dll extension is uncommented (for PHP 5 or newer).
 
Add  PHP folder to the system path:


You should add "C:\php" to the server's PATH environment variable, you can do this by:

  • Right-click on My Computer, choose Properties
  • Flip to the Advanced tab
  • Click the Environment Variables button
  • Double-click the Path variable in the list of System variables.
  • Either add "c:\php;" to the beginning or ";c:\php" to the end
  • Restart IIS for it to take effect. (in DOS type IIS stop and then IIS start)

 


IISRESET.EXE (c) Microsoft Corp. 1998-1999

 

Usage:
iisreset [computername]

    /RESTART            Stop and then restart all Internet services.
    /START              Start all Internet services.
    /STOP               Stop all Internet services.
    /REBOOT             Reboot the computer.
    /REBOOTONERROR      Reboot the computer if an error occurs when starting,
                        stopping, or restarting Internet services.
    /NOFORCE            Do not forcefully terminate Internet services if
                        attempting to stop them gracefully fails.
    /TIMEOUT:val        Specify the timeout value ( in seconds ) to wait for
                        a successful stop of Internet services. On expiration
                        of this timeout the computer can be rebooted if
                        the /REBOOTONERROR parameter is specified.
                        The default value is 20s for restart, 60s for stop,
                        and 0s for reboot.
    /STATUS             Display the status of all Internet services.
    /ENABLE             Enable restarting of Internet Services
                        on the local system.
    /DISABLE            Disable restarting of Internet Services
                        on the local system.

 

Configure IIS


For these steps, open IIS Manager
(Start -> Control Panel -> Administrative Tools -> Internet Information Services (IIS)  Manager).
Then add new extension (.php)

  • Expand the local computer in the left pane
  • Right-click on "Web Sites" in the left pane, then click "Properties" in the menu that pops up
  • Flip top the Home Directory tab
  • Click "Configuration"
  • Flip to the Mappings tab
  • Click Add...
  • Enter the full path to php5isapi.dll in the "Executable" textbox (Browse... to find it more easily if you need to)
  • Enter ".php" in the Extension textbox
  • Select radial button Limit to, enter "GET,POST,HEAD"
  • Click OK all the way out

Testing your Configuration:

Create a new file named test.php in one of the websites. Expand the Web Sites folder in the left pane of IIS Manager to see a list of existing websites. Right-click on a website -> Properties -> Home Directory -> Local Path will show you where the website root directory is (in our case its c:\inetpub\wwwroot\.

Create a test.php file with the following line:

<?php
phpinfo();
?>

With your browser navigate to http://localhost/test.php

 

Example:

Thats It.

php tutorials