Dreamweaver

Install a PHP application server

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.

Install the PHP application server in Windows

  1. If applicable, log into your Windows system using the Administrator account.
  2. Download the Windows PHP 5.x installer from the PHP website at www.php.net/downloads.php.
  3. Double-click the installer file you downloaded and follow the onscreen installation instructions.
  4. 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.

    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.

  5. 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.

  6. 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.

  7. Delete the semicolon at the start of the line to enable the extension.

    extension=php_mysql.dll

  8. Save and close the php.ini file.
  9. 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.

  10. Restart IIS.

    After installing PHP, you can test the server to make sure it works properly. See the next section.

Test the PHP installation in Windows

  1. In Dreamweaver or any text editor, create a plain text file and name it timetest.php.
  2. 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.

  3. Copy the file to the C:\Inetpub\wwwroot folder of the Windows computer running IIS.
  4. In your web browser, enter the URL of your test page, and then press Enter.

    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.

    Note: Looking at the source code (View > Source In Internet Explorer) will confirm that the page does not use any client-side JavaScript to achieve this effect.

    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.

To install the PHP application server on the Macintosh

  1. If applicable, log into your Macintosh system using the Administrator account.
  2. Create a folder named webapps in your main user folder, Users/your_user_name/webapps).
  3. From the Entropy web site at www.entropy.ch/software/macosx/php/, download the PHP for 5.x for Apache 1.3 package (for example, entropy-php-5.2.0-3.tar.gz) and save it in your webapps folder.
  4. On your Macintosh, open Terminal (Applications/Utilities) and change the default folder to webapps by typing the following line on the Command line and pressing Enter:

    cd webapps

  5. In Terminal, uncompress the gz file by typing gunzip followed by the name of the gz file in your webapps folder.

    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

    Note: Do not use Stuffit Expander to uncompress the file.
  6. In Terminal, open the tar archive that was uncompressed by typing tar xf followed by the name of the tar file. Example:

    tar xf entropy-php-5.2.0-3.tar

    An installer package called entropy-php.mpkg is extracted from the archive.

  7. Double-click the installer package entropy-php.mpkg and follow the onscreen instructions.

    After installing PHP, you can test the server to make sure it works properly. See the next section.

Test the PHP installation on the Macintosh

  1. In Dreamweaver or any text editor, create a plain text file and name it timetest.php.
  2. 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 the page when was processed on the server.

  3. Copy the file to the /Users/your_user_name/Sites folder on your Macintosh.

    This Sites folder is your personal root folder for the Apache web server.

  4. In your web browser, enter the following URL and press Return:

    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.

    Note: Looking at the source code (View > View Source In Safari) will confirm that the page does not use any client-side JavaScript to achieve this effect.

    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.