Setting up a Testing Server on your Computer

Setting up a PHP/MySQL testing server on your own computer is an invaluable time saver for web developers. Once set up and functioning properly, you can develop, test, and prep your dynamic sites without having to upload to your live server every time you make a change. Mac OS X comes with an Apache server and PHP installed by default, but they lack a great deal of the useful tools you will be using and they require you to be comfortable using Terminal which many new developers can find cumbersome.

This tutorial shows you how to get around using Terminal and easily set up your Mac to run a PHP/MySQL testing environment that you can use for testing PHP pages. If you are a Windows user and want to set up a testing server view the tutorial for Installing XAMPP on Windows.

What you need to start:

  • Mac OS X
  • MAMP for Mac OS X (Basic DMG package) - http://www.mamp.info/en/index.html
  • Do I need a Testing Server?

    In most cases, having a local testing server will save you time and make developing your dynamic website easier.  However, depending on the extent to which a customer is developing websites, this may not be necessary.

    You might not need a PHP testing server if…
    • …you are not creating/modifying PHP pages.
    • …you are using a WebAssist Solution Pack and have no intention of customizing the code or functionality.

      In this case, you should upload the Solution Pack directly to your server after modifying the necessary configuration files.

    • …you are using a product that creates PHP pages but you don’t need to test until you upload to your live server.
    You definitely want a PHP testing server if…
    • …you are using eCart, DataAssist, or SecurityAssist to create a dynamic application. This will significantly speed up your development process.
    Turn off Apache

    If you have ever enabled (or attempted to enable) a testing server on your Mac using the default Apache server, you will want to turn that off now to avoid conflicts.

    1. Open your System Preferences.
    2. Choose Sharing.
    3. Make sure Web Sharing is turned off.
    Step 1: Install MAMP

    MAMP installs everything you need to run PHP pages and a MySQL database on your local machine.

    1. Double-click the zip (.zip) file you downloaded from the MAMP website to "unzip" the file.
    2. After the zip is unarchived, double-click the Installer.dmg file that appears.
    3. In the MAMP & MAMP PRO Installer window that displays, simply drag the MAMP folder into the Applications folder to begin the Installation.
    4. XAMPP Installer

     

    NOTE:The installation process can take up to a few minutes. After installation is completed you can access the MAMP control panel at any time from within the MAMP folder in your Applications folder.

    Step 2: Start your Server

    Once installed, you can use the MAMP Control Panel to start your testing server.

    1. Open your Applications folder. Then, open the MAMP folder.
    2. Open the MAMP Control Panel by clicking on the MAMP icon.
       

      NOTE:When the MAMP Control Panel opens, it will also open a browser window for managing your server settings. Close this window for right now and return to the Control Panel.

    3. The Apache and MySQL Servers begin running by default when MAMP is opened. To shut them off or restart them, use the Stop Servers and Start Servers buttons.
      Starting these services can take a few seconds.  When it is complete, a green circle will display beside each option.
    4. MAMP Control Panel

    5. To make your testing server stay on even after closing MAMP, choose the Preferences option and uncheck the 'Stop Servers when quitting MAMP' checkbox in Preferences.
    6. MAMP Preferences

    Change the Port Numbers
    To ensure the testing server works on the default port (80), you should change the port numbers used.
    1. Click Preferences
    2. Choose the Ports tab.
    3. Select the Set to default Apache and MySQL ports button.
    4. Click OK.
    5. MAMP Ports

    Step 3: A little cleanup

    With your testing server now installed and running, there are a few final steps you should take to make sure everything is configured to work perfectly.

    1. Click the Open start page button on the MAMP Control Panel.
      You should now see a confirmation window informing you that ‘MAMP is installed on your Mac and everything is working!’ This interface allows you to configure certain MAMP settings
      Test the PHP Installation

      You should test your PHP Installation to make sure everything is set up for you to load PHP pages on your local computer.

    1. Navigate back to the http://localhost/MAMP/page you were at before.
    2. Click the phpinfo option from the top navigation.

      This page displays the login credentials for your MySQL database. The username (SuperUser), 'root' is created for you automatically and is the username you can use for accessing your MySQL database or creating a database connection.

      phpinfo

      If you see a PHP page similar to this, you have completed setting up your PHP/MySQL testing server.

    What to do next...

    Now that your testing server is completely set up, you can preview PHP pages on your local computer.  The location on your computer to place your files by default is Applications:MAMP:htdocs. You can change this in the Apache tab in the MAMP Control Panel Preferences.

    MAMP Directory

    Now, you should define a site in Dreamweaver that references your testing server. For instructions, see the Defining your site for dynamic development tutorial.

    Feedback on this tutorial?

    If you did not find this helpful or you are stuck on a particular step, click here to let us know what we can do to improve this tutorial.

      • Required *
      • Invalid format.Please enter a full email address
        Please provide a comment
      • Security Code
        Entered text does not match; please try again

    This form was built using CSS Form Builder.