Accessibility

Table of Contents

Setting up a PHP development environment for Dreamweaver

Install MySQL and phpMyAdmin separately

The instructions on this page apply only if you decide to use IIS as your web server on Windows or if you use the preinstalled versions of Apache and PHP on Mac OS X. If you installed XAMPP or MAMP, skip to the next page where you'll learn how to define a PHP site in Dreamweaver.

This section covers the following topics:

Note: The current version of PHP (5.2.8) does not support MySQL 5.1. You must install MySQL 5.0.

Install MySQL in Windows

This section describes how to download and install the MySQL 5.0 Community Edition database server on your Windows computer.

Note: The instructions in this section apply to the "Windows Essentials" installer for MySQL 5.0. For other versions, please see the MySQL documentation for possible differences in the installation procedure. You need to be logged into Windows in an Administrator account. In Windows Vista, it is advisable to disable User Access Control (UAC) temporarily during installation.

  1. Download the Windows Essentials installer from the Windows Downloads category on the MySQL download page:

    http://dev.mysql.com/downloads/mysql/5.0.html#win32

    You'll find different versions for 32-bit and 64-bit systems. The correct version for 32-bit Windows is Windows Essentials (x86).

  2. Double-click the MSI file you downloaded and follow the onscreen instructions.

    Note: Select Typical Install when prompted.

  3. When the setup wizard is done, select the Configure the MySQL Server Now option on the setup wizard's last page and click Finish to run the configuration wizard.

    Note: If you missed the option in the setup wizard, you can open the configuration wizard by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Server Instance Config Wizard.

  4. In the MySQL Server Instance Configuration Wizard, make the following choices:
    • For configuration type, select Detailed Configuration.
    • For server type, select Developer Machine.
    • For database usage, select Non-Transactional Database Only.
    • For the number of concurrent connections, select Decision Support(DSS)/OLAP.
    • For networking options, accept the default settings.
    • For the default character set, accept the default setting.
    • For the Windows options, select both options: Install As Windows Service and Include Bin Directory in Windows Path.
    • For security options, enter a root password and confirm it.
  5. Click Execute to configure your database server.

The next step is to install phpMyAdmin, a graphical front end for MySQL. The instructions follow the next section, which shows Mac users how to install MySQL.

Install MySQL on a Mac

This section describes how to download and install the MySQL 5.0 Community Edition database server on your Mac.

Note: The instructions in this section apply to the package format (DMG) installer of MySQL 5.0 for the Mac. For other versions, refer to the readme file that comes with the installer for possible differences in the installation procedure.

  1. Download an installer package from the "Mac OS X (package format) downloads" category on the MySQL download page:

    http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

    Be sure you select the correct version for your operating system and processor. If your Mac has an Intel processor, select the package marked "x86."

  2. Double-click the DMG file you downloaded to mount the disk image and display its contents.
  3. Double-click the mysql-standard-x.x-x.pkg file and follow the onscreen instructions.

    Note: If you have an Intel Mac, you may see the following error message in the destination disk selection dialog box: "You cannot install this software on this disk. (null)." If this error occurs, click the Go Back button once to return to the previous screen, and then click Continue to advance to the dialog box again. You should now be able to choose the destination disk.

  4. After the installation of the database server is complete, install a button to start and stop the database server by double-clicking the MySQL.prefPane file in the installation disk image, and then follow the onscreen instructions.

    This small installer places a stop and start button in your system preferences to control the server. The button can be accessed through a new MySQL icon under the Other category in the System Preferences dialog box.

  5. Click the MySQL icon in System Preferences, and click Start MySQL Server. Enter your Mac password when prompted. After a few moments, the MySQL preference pane should report that MySQL is running.
  6. Close the MySQL preference pane.

    A new installation of MySQL is not password-protected, so you need to set a password for the administrative superuser called root.

  7. Select Applications > Utilities to launch Terminal.
  8. Enter or paste the following instruction at the command prompt: /usr/local/mysql/bin/mysql -uroot

    The MySQL command prompt appears:

    mysql>
  9. Switch to the main database that contains details of user accounts and privileges by typing use mysql; followed by Return.

    Note: All commands typed at the MySQL command prompt must end with a semicolon followed by Return. If you forget to type the semicolon before pressing Return, type the semicolon at the command prompt and press Return again.

  10. Now enter the command to set the password for the root superuser, using your own password in place of "secret."
    UPDATE user SET password = PASSWORD('secret') WHERE user = 'root';
  11. Next, remove anonymous access to MySQL:
    DELETE FROM user WHERE user = '';

    Note: The quotes before the semicolon are two single quotes with no space in between.

  12. Tell MySQL to update the privileges table:
    FLUSH PRIVILEGES;
  13. Exit the MySQL monitor by typing exit; followed by Return. This ends your session with the MySQL monitor. It does not shut down the MySQL server.

Note: Installing a standalone version of MySQL on Mac OS X 10.5 often results in an error message that PHP cannot connect to MySQL. There are several ways to solve this problem. One of the easiest is to create a symlink (alias) so that PHP finds the connection socket, mysql.sock, where it expects it to be. Open Terminal, and enter the following command followed by Return:

sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Enter your Mac password when prompted.

From now on, all your interaction with MySQL will be through Dreamweaver or phpMyAdmin, which you'll install next.

Install phpMyAdmin

Since phpMyAdmin is PHP based, all that's needed to install it is to download the files, unzip them to a website in your local testing environment, and create a simple configuration file. phpMyAdmin 3 requires a minimum of PHP 5.2 and MySQL 5.0. If you are running earlier versions, you must install phpMyAdmin 2.

  1. Go to http://www.phpmyadmin.net and download the version you require.
  2. Unzip the downloaded file. It will extract the contents to a folder called phpMyAdmin-x.x.x, where x represents the version number.
  3. Highlight the folder icon, and cut it to your clipboard. On Windows, paste it inside your web server root (with IIS, this is normally C:\Inetpub\wwwroot). If you're on a Mac, put the folder in Macintosh HD:Library:WebServer:Documents.
  4. Rename the folder you have just moved to phpmyadmin.
  5. Create a new subfolder called config within the phpmyadmin folder.

    Windows users skip to step 7. Mac users continue with step 6.

  6. On Mac OS X, use Finder to locate the config folder you have just created. Press Cmd+I to bring up an Info panel.
  7. In Ownership & Permissions, expand Details, and click the lock icon so that you can make changes to the settings. Change the setting for Others to Read & Write. Close the Info panel.
  8. Open a browser, and type the following into the address bar: http://localhost/phpmyadmin/setup/index.php. (If installing phpMyAdmin 2, the address should be http://localhost/phpmyadmin/scripts/setup.php.)
  9. Ignore any warning about the connection not being secure. This warning is intended for server administrators installing phpMyAdmin on a live Internet server.
  10. Click the Add button in the Servers section. This loads a form with most of the necessary information already filled in. Check the following settings:
    • Server hostname: localhost
    • Server port: Leave blank unless your web server is running on a nonstandard port, such as 8080
    • Server socket: Leave blank
    • Connection type: tcp
    • Authentication type: config
    • User for config auth: root
    • Password for config auth: Enter your MySQL root password
  11. Scroll down to the Actions field, and click Add. You'll see two buttons labeled Add. Make sure you click the one that has a Cancel button alongside.

    The next screen will probably warn you that you didn't set up a phpMyAdmin database, so you won't be able to use all the phpMyAdmin features. This is not important. You can set up one later if you decide to use the advanced features of phpMyAdmin.

  12. Scroll down to the Configuration section near the bottom of the page, and click Save.
  13. Open the config folder in Explorer or Finder. You should see a new file called config.inc.php. Move it to the main phpmyadmin folder. The official instructions tell you to delete the config folder, but this isn't necessary in a local testing environment.

Now that you have a PHP development environment, you're ready to define a PHP site in Dreamweaver, as described on the next page.