Download ArticleDownload Article

This How.com.vn will teach you how to run a PHP script in your web browser using a free web server called MAMP. Unlike a regular HTML file, you can't just double-click a PHP file to run a script in your browser. Web servers like MAMP will translate your code to something that can be interpreted appropriately by any web browser on your computer.

  1. How.com.vn English: Step 1 Go to https://www.mamp.info/en/downloads....
    Go to https://www.mamp.info/en/downloads. MAMP is a free, local server environment that you'll need to use to see PHP in your web browser.
  2. How.com.vn English: Step 2 Click the download link for your operating system.
    If you're using a Windows PC, you'll run the downloaded file, then follow the installer wizard install MAMP. If you're using a Mac, you'll run the downloaded file, then drag-and-drop the MAMP file icon to your Applications folder.
    Advertisement
  3. How.com.vn English: Step 3 Open MAMP.
    You'll find this program in your Start Menu or Applications folder in Finder once it's installed.
  4. How.com.vn English: Step 4 Click Preferences.
    This grey gear icon is on the left side of the window that opens when you launch MAMP.
  5. How.com.vn English: Step 5 Check that all the defaults are set correctly.
    Click through the tabs on the top and check to make sure the information is listed similarly so your server works.
    • In the Start/Stop tab, make sure "Start Servers" and "Open WebStart Page" are checked under "When starting MAMP." "Stop servers" should be selected under "When quitting MAMP."[1]
    • On the Ports tab, enter 8888 in the text field next to "Apache Port," "Nginx Port," and 8889 in the text field next to "MySQL Port."[2]
    • On the PHP tab, select "7.1.1" if it's not already selected.
    • On the Web Server tab, select "Apache" if it's not already selected.
  6. How.com.vn English: Step 6 Map to your folder that contains the PHP file.
    You can have multiple PHP files in that folder, but make sure you map a folder instead of a file by dragging and dropping the folder from your file browser.[3]
    • For example, you can open your file browser and navigate to your PHP file, navigate one folder back, then drag-and-drop it in the open window. You'll have MAMP set to the folder that your PHP file is inside, not the file ending in .PHP.
  7. How.com.vn English: Step 7 Click OK to apply your changes to preferences before continuing.
    This might take about 20 seconds.[4]
  8. How.com.vn English: Step 8 Click Start Servers.
    This power icon button is toward the right side of the window that opens when you launch MAMP. Enter your computer password and username when prompted to continue.
  9. How.com.vn English: Step 9 Open your browser.
    You can use any browser to preview your PHP file.
  10. How.com.vn English: Step 10 ↵ Enter
    Navigate to "localhost:8888" in your browser's address bar. The address bar is where you normally see "https://www." To do this, type "localhost:8888" and press (Windows) or Return (Mac). You'll see a directory of your PHP files displayed on the page.
  11. How.com.vn English: Step 11 Click the PHP file to run the script in your browser.
    Your PHP file now run and display its output in the browser window.
  12. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!

      About This Article

      How.com.vn English: Darlene Antonelli, MA
      Written by:
      How.com.vn Technology Writer
      This article was co-authored by How.com.vn staff writer, Darlene Antonelli, MA. Darlene Antonelli is a Technology Writer and Editor for How.com.vn. Darlene has experience teaching college courses, writing technology-related articles, and working hands-on in the technology field. She earned an MA in Writing from Rowan University in 2012 and wrote her thesis on online communities and the personalities curated in such communities. This article has been viewed 65,853 times.
      How helpful is this?
      Co-authors: 2
      Updated: February 10, 2020
      Views: 65,853
      Article SummaryX

      1. Download MAMP at https://www.mamp.info/en/downloads/.
      2. Open MAMP.
      3. Click Preferences.
      4. Check that all the defaults are set correctly.
      5. Map to your folder that contains the PHP file.
      6. Click OK to apply your changes to preferences before continuing.
      7. Click Start Servers.
      8. Open your browser.
      9. Type "localhost:8888" in your browser's address bar.
      10. Press Enter or Return on your keyboard.
      11. Click the PHP file to view it.

      Did this summary help you?

      Thanks to all authors for creating a page that has been read 65,853 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement