PHP is a scripting language that is best suited for web applications. When a user types in an address in their web browser, if the web page at that address has PHP code in it and has a .php extension, then a couple of things happen:
- The PHP code executes on the server.
- The output from the PHP execution is inserted into the web page.
- The web page is sent to the user's browser in the form of HTML.
This lesson assumes that you have the Apache web server installed on your local machine. If you do not, please go over our Installing Apache Web Server tutorial first.
To install PHP on your local machine, follow these steps:
- Click http://windows.php.net/download/ to take you to the Windows subdomain of the PHP language website. This page specifically is the Windows download page.
- From the pull-down menu, pick the VC6 or VC9 Thread Safe version of PHP. We use the VC6 version because we are installing it on top of the Apache web server.
- Click on the "Installer" link in the VC6 or VC9 Thread Safe section.
- When the download dialog appears, click Run.
- After the file downloads, the Security Warning will appear. Click Run.
- When the installation wizard dialog first opens, click Next.
- To accept the license terms, check "I accept the terms in the License Agreement" and click Next.
- Choose the default Destination Folder and click Next.
- Here, select the "Apache 2.2.x Module", then click Next.
- On the next dialog, browse to find the Apache configuration folder. For the default Apache installation, the path is: C:\Program Files\Apache Software Foundation\Apache2.2\conf\. Click Next.
- Leave the default installation choices as is and click Next.
- Click Install to begin the actual installation.
- It may take a couple minutes to install. During install, a "User Account Control" dialog may pop up; click Allow to proceed.
- Click Finish to exit the installation.
- Go to C:\Program Files\Apache Software Foundation\Apache2.2\conf\.
- Open the httpd.conf file in Notepad or another text editor.
- Find this text in the file:
- Next, you may have to fix an error in the PHP install. Search for this text:
- Save the file.
- Go to your taskbar.
- Right-click on the Apache Monitor icon and select "Open Apache Monitor".
- Restart the Apache2.2 Server.
- Click OK.
<IfModule dir_module> DirectoryIndex index.html </IfModule>
and change it to this:
<IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir "" LoadModule php5_module "php5apache2_2.dll" #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
If the PHPIniDir variable is empty, and the LoadModule php5_module only has the .dll name and not the full path, you'll need to add paths to each, like this (I use the default install path here):
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL PHPIniDir "C:\Program Files (x86)\PHP" LoadModule php5_module "C:\Program Files (x86)\PHP\php5apache2_2.dll" #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
Now you have successfully installed PHP and configured it to run on the Apache web server on your local machine.
If you have any questions or comments, please post them in our Forum.