To set up a PHP development environment, you must first set up or get access to a PHP application server. An application server is software that helps a web server process web pages containing server-side scripts or tags. When such a page is requested by a browser, the web server hands the page off to the application server for processing before sending the page to the browser.
This section describes how to install PHP 5 on your Windows computer. PHP is open source software that you can use for developing, testing, and deploying web applications. For more information, see the PHP documentation at www.php.net/download-docs.php.
If you're a Macintosh user, see Set up a PHP application server (Macintosh).
This section contains the following topics:
First, you need a web server. PHP installs as an extension to an existing web server, enabling the web server to process PHP files. Windows XP Professional users can install and run the Microsoft Internet Information Server (IIS) web server on their local computer, as described in this section.
Check to see if IIS is installed and running on your system. The way to do this is to look for the C:\Inetpub folder. If it doesn't exist, install IIS as follows.
In Dreamweaver or any text editor, create a plain text file called myTestFile.html and enter the following line in the HTML code:
<p>My web server is <em>working</em>.</p>
Save the HTML file in the following folder on your computer:
C:\Inetpub\wwwroot\Enter the following URL in your web browser:
http://localhost/myTestFile.htmIf the browser displays your page and the word "working" is in italics, the web server is running normally. If the page doesn't open as expected, make sure the URL does not contain any errors.
The correct download link is "PHP 5.x.x installer" under Windows Binaries.
At the Choose Items To Install screen, click the Plus (+) button next to Extensions, locate MySQL in the list, and then select the Will Be Installed On Local Hard Drive option.
Many developers use a MySQL database server to build their PHP applications. With PHP 5, however, the MySQL extension that allows PHP to work with a MySQL database server is not installed or enabled by default by the Windows installer.
In the PHP installation folder (likely C:\Program Files\PHP), locate the file called php.ini and open it in Notepad.
You must edit this file to enable the MySQL extension.
Find the following line in the php.ini file:
;extension=php_mysql.dll
The semicolon (;) at the start of the line tells PHP to ignore the line.
Delete the semicolon at the start of the line to enable the extension.
extension=php_mysql.dll
In the PHP installation folder, locate the file called libmysql.dll and copy it to the C:\Windows\system32 folder.
This file is required so that IIS can work with PHP 5 and MySQL.
You can also restart IIS by selecting Start > Control Panel > Administrative Tools, and then double-clicking the Internet Information Services icon to open the IIS console. In the directory tree in the console's left pane, select your default web site and then select Actions > Stop. After a few moments, select Actions > Start.
After installing PHP, test the server as described next.
In the file, enter the following code:
<p>This page was created at
<b><?php echo date("h:i:s a", time()); ?></b> on the computer running PHP.</p>
This code displays the time when the page was processed on the server.
If PHP is running on your local computer, enter the following URL:
http://localhost/timetest.php
The test page should open and display the time of day. The specified time is known as dynamic content because it changes every time you request the page. Click your browser's Refresh button to generate a new page with a different time.
If the page doesn't work as expected, check for the following possible errors:
After successfully installing and testing the server software, create a root folder for your web application as described in the next section.
You should create a root folder to store all the files of your web application. If IIS is running on your computer, a good place to create the folder is in the Inetpub/wwwroot/ folder, as in the following example:
C:\Inetpub\wwwroot\MyWebAppThe IIS web server will serve any page in the wwwroot folder or in any of its subfolders in response to an HTTP request from a web browser.