close ad
 
Important WebAssist Announcement
open ad
View Menu

Web development tutorial

Set up a test server on Mac OS

Tutorial created by Ray Borduin, WebAssist

Categories: MySQL, PHP

rating

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.

arrow downRelated tutorials

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.

arrow downWhat you need to start

  1. Mac OS X
  2. MAMP for Mac OS X (Basic DMG package) - http://www.mamp.info/en/index.html

arrow downDo 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.

Step 1: 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.

Step 2: 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.

arrow downTurn Off Apache

IMPORTANT! Apache comes standard on many Mac computers, and will definitely be running if you've ever ever enabled (or attempted to enable) a testing server on your Mac using the default Apache server. Even if you didn't turn it on, let's make sure it's off to avoid conflicts.

  1. Open your System Preferences.
  2. Choose Sharing.
  3. Make sure the checkbox next to Web Sharing is turned off.

arrow downInstall 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.
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.

arrow downStart 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.
    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. 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.

Step 1: 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.

arrow downA 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.

Step 1: Confirm MAMP is working

  1. Open the MAMP Control Panel.
  2. Click the Open Start Page button.


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

Step 2: 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.


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

arrow downWhat 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.


Now, you should define a site in Dreamweaver that references your testing server.

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments
rating

Daryl: 11 Years, 1 Month, 6 Days, 23 Hours, 32 Minutes ago

Im waiting for my first Mac to arrive and thought I would read up first.

I am currently running EasyPHP on my Windows setup which allows me to setup aliases which I can then point to the folder that I am working in for each website. Can you do this in MAMP or would you need to create a new folder in /Applications/MAMP/htdocs for each site and then have duplicates of each website on your computer?

Jason Byrnes: 11 Years, 1 Month, 6 Days, 15 Hours, 56 Minutes ago

Hi Daryl,

MAMP has 2 flavors, the basic Free Version, and MAMP Pro. In the basic Free version, you can only set the document root, you cannot create aliases using the MAMP Control Panel. The Pro Version does allow for setting aliases in the MAMP Control panel.

However, in both versions you can create aliases by editing the Apache httpd.conf file. It takes some experience with Apache to do this, but the documentation is available on the apache website:
http://httpd.apache.org/docs/2.2/mod/mod_alias.html

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.