How to Set Up for PHP Training

Whether you are using a PC with Windows or a Mac, you should install MAMP for the PHP course.

MAMP is a free distribution package that makes it easy to install Apache Web Server, PHP, and MySQL. Before installing MAMP, you should turn off any other web servers and instances of MySQL you have running on your computer.

These instructions will walk you through:

  1. Downloading MAMP.
  2. Running MAMP on Windows / Mac
  3. Downloading and unzipping the class files.
  4. Setting the MySQL password.
  5. Installing the poetree database.
  6. Testing your setup.
  7. Download, Install, and Set Up Visual Studio Code

Recommended Code Editor

While you may use a different editor or IDE, we highly recommend using Visual Studio Code. Visual Studio Code is an excellent IDE to learn to code on. It provides a nice balance of power and simplicity and it is available on Windows and Mac. When you have finished the instructions on this page, learn how to download, install, and set up VS Code.

Downloading MAMP

Windows users should not download v. 4.1.1.

Windows users: If the latest version of MAMP shown on the download page is 4.1.1, download version 4.1 instead.

  1. Download the latest version of MAMP. Be sure to choose the version for your operating system:Download MAMP
  2. Run the downloaded file (e.g., MAMP_MAMP_PRO_4.1.exe for Windows ro MAMP_MAMP_PRO_5.5.pkg for Mac) and click through the installation wizard.
    1. If prompted, you do not need to install MAMP PRO or Apple Bonjour.
    2. Accept the License Agreement.
    3. Accept all the defaults.
    4. Close the wizard when setup is finished.

Running MAMP on Windows

Careful!

Be very careful to follow these steps exactly. MAMP can be finicky. If something goes wrong, often the easiest thing to do is uninstall MAMP and start the process over again.

To run MAMP on Windows...

  1. Navigate to C:\MAMP in Windows Explorer and open MAMP.exe. If you get a security alert, allow access. You should see a window like this one:MAMP control window The servers (Apache Server and MySQL Server) should have automatically started. If they did not, start them by clicking on Start Servers.
  2. Open MAMP Preferences: Open MAMP Preferences
  3. Change the Apache port to 8888: Open MAMP Preferences
  4. Click on Open WebStart Page: Open MAMP Preferences The following page should open in your browser:MAMP Start Page
MAMP Bug on Windows

The current version of MAMP on Windows has a bug: MAMP sometimes fails to start and stop MySQL on Windows when the Start Servers or Stop Servers button is pushed. If you experience this problem, see this video to learn how to resolve it.

Running MAMP on Mac

To run MAMP on Mac...

  1. Navigate to /Applications/MAMP in Finder and open MAMP.app. If you get a security alert, allow access. You should see a window like this one:MAMP control window - Mac Start the servers (Apache Server and MySQL Server) by clicking on Start Servers.
  2. The MAMP WebStart page should automatically open. If it does not, click on Open WebStart Page: Open MAMP Preferences - Mac The following page should open in your browser:MAMP Start Page

Class Files

  1. Download the class files...
    • Windows users...
      1. Create a folder in C:\MAMP\htdocs named "Webucator"
      2. Download the class files anywhere you like (e.g, the Downloads folder).
      3. Extract your class files into the new Webucator folder:Extract Class Files
    • Mac users...
      1. Create a folder in /Applications/MAMP named "Webucator".
      2. Download the class files into the new Webucator folder.
      3. Double click on the downloaded zip file to extract your class files into the new Webucator folder.
  2. You can now delete the zip file.
  3. Rename the ClassFiles folder to php:
    • Windows: Path to Class Files - Windows
    • Mac: Path to Class Files - Mac
  4. To test that your setup so far is correct, open your browser and navigate to http://localhost:8888/Webucator/php/. You should get a listing like this:Class Files Listing
  5. Click PHPBasics, then click Demos, and then hello-world.php. You should get a page that looks like this:Hello World!

Setting the MySQL Password

The PHP files use "pwdpwd" for the MySQL root password, while the default password used in MAMP is "root". In your browser, navigate to http://localhost:8888/phpMyAdmin/.

Note: It is important to do these steps in the order specified.

  1. Click the mysql database on the left.
  2. Click the SQL tab at the top.
  3. Enter the following in the textbox under Run SQL query/queries on database mysql:
    SET Password = 'pwdpwd'
  4. Click Go.phpMyAdmin change password
  5. You also need to update the password in phpMyAdmin:
    • Windows: Open C:\MAMP\bin\phpMyAdmin\config.inc.php in your editor (e.g., Visual Studio Code)
    • Mac: Open /Applications/MAMP/bin/phpMyAdmin/config.inc.php in your editor (e.g., Visual Studio Code)
  6. Change the password setting as show below to 'pwdpwd'.Change password in phpMyAdmin config file

Installing the poetree Database

Use phpMyAdmin to install the poetree database used in class.

  1. Click on the Import tab heading
  2. Click the Choose File button.
  3. Browse to the poetree-db.sql file in your class files (C:\MAMP\htdocs\Webucator\php\poetree-db.sql or /Applications/MAMP/htdocs/Webucator/php/poetree-db.sql).
  4. Click Open: Import poetree Database
  5. Click the Go button on the bottom left of the page.
  6. You should get a Success message and poetree should be added to your list of Databases.phpMyAdmin Database List

Testing the Setup

Point your browser to http://localhost:8888/Webucator/php/Database/Solutions/phppoetry.com/. If you see a page like this, you're all set:Poetree Site

And that's it for MAMP

Happy MAMPing! Don't forget to go download, install, and set up VS Code.