To run PHP pages, you need the PHP application server, which is open-source software available on the web. Editions of the application server exist for Windows, Linux, UNIX, HP‑UX, Solaris, and Mac OS X systems.
For more information on the application server, see the PHP documentation, which you can also download from the PHP website at www.php.net/download-docs.php.
With PHP 5, the MySQL extension that allows PHP to work with a MySQL database server is not installed or enabled by default by the Windows installer.
You must edit this file to enable the MySQL extension.
;extension=php_mysql.dll
The semicolon (;) at the start of the line tells PHP to ignore the line.
extension=php_mysql.dll
This file is required so that IIS can work with PHP 5 and MySQL.
After installing PHP, you can test the server to make sure it works properly. See the next section.
<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 you installed PHP on your local computer, you can 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:
The file does not have a .php extension.
You typed the page’s file path (C:\Inetput\wwwroot\timetest.php) instead of its URL (for example, http://localhost/timetest.php) in the browser’s address text box.
If you type a file path in the browser (as you might be used to doing with normal HTML pages), you bypass the web server and the application server. As a result, your page never gets processed by the server.
The URL contains a typing mistake. Check for errors and make sure the filename is not followed by a slash, such as http://localhost/timetest.php/.
The page code contains a typing mistake.
After installing and testing the server software, create a root folder for your web application. See Creating a root folder for the application.
cd webapps
For example, if you downloaded entropy-php-5.2.0-3.tar.gz, enter the following command and press Enter:
gunzip entropy-php-5.2.0-3.tar.gz
tar xf entropy-php-5.2.0-3.tar
An installer package called entropy-php.mpkg is extracted from the archive.
After installing PHP, you can test the server to make sure it works properly. See the next section.
<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 the page when was processed on the server.
This Sites folder is your personal root folder for the Apache web server.
http://localhost/~your_user_name/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:
The file does not have a .php extension.
The URL contains a typing mistake. Check for errors and make sure the filename is not followed by a slash, such as http://localhost/~your_user_name/timetest.php/. Also make sure you included the tilde (~) before your user name.
The page code contains a typing mistake.
The Apache server is not running. Look in System Preferences, in the Sharing category, to see whether Personal Web Sharing is enabled.
After testing and testing the server software, create a root folder for your web application. See Creating a root folder for the application.