How to use MAMP (Mac Apache MySql php)

MAMP setup

Running your project with MAMP

MAMP - basic usage

  • Click ‘Start’ button to start Apache, PHP, MySQL
  • Click the ‘Preferences’ cog button to:
    • Set port number for Apache and MySQL
      e.g. Apache Port: 80, MySQL Port: 3306
    • Set the root folder of the project 
      e.g. Users/UserName/Sites/Project/public_html
  • If the desired PHP version is not listed in the php drop down of MAMP:
    • Rename other php folders in Applications/MAMP/bin/php — MAMP only shows 2 of the latest php versions
      e.g. rename ‘php8.0.0’ too ‘php8.0.0_RENAME_TO_ENABLE’
  • Log files:
    • All log files are stored in: /Applications/MAMP/logs/
    • The logs need to be enabled on Apache, in the file: /Applications/MAMP/conf/apache/httpd.conf
      #CustomLog /Applications/MAMP/logs/apache_access_log combined
      — remove '#' to uncomment this line:
      CustomLog /Applications/MAMP/logs/apache_access_log combined
    • Apache will write the access logs into /Applications/MAMP/Library/logs/access_log.
  • Restart MAMP Apache server: press 'Stop' button, then 'Start' button.

Config files

Add a new project:

  • Add a new item to hosts list in: /etc/hosts
  • Add a new block in the config file:
    • Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
    • Make sure all the paths are correct
  • Restart MAMP

Useful information:

  • If you want to maintain multiple domains/hostnames on your machine you can setup VirtualHost containers for them.
  • Most configurations use only name-based virtual hosts so the server doesn't need to worry about IP addresses.
  • You may use the command line option '-S' to verify your virtual host configuration.

Example of the httpd-vhosts.conf file:

# Virtual Hosts
# Required modules: mod_log_config
# Use name-based virtual hosting.

NameVirtualHost *:80
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests
# that do not match a ServerName or ServerAlias in any block.

    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Applications/MAMP/Library/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
##################################
#   EXAMPLE PROJECT 1
##################################

  AcceptPathInfo on
    DocumentRoot /Users/UserName/Sites/ExampleProject1/public_html
    ServerName dev.example1
    ErrorLog /Users/UserName/Sites/ExampleProject1/logs/error.log
    CustomLog /Users/UserName/Sites/ExampleProject1/logs/access.log common
    DirectoryIndex index.php
    AllowOverride all
    Order allow,deny
    Allow from all
##################################
#   EXAMPLE PROJECT 2
##################################

 AcceptPathInfo on
    DocumentRoot /Users/UserName/Sites/ExampleProject2/public_html
    ServerName dev.example2
    ErrorLog /Users/UserName/Sites/ExampleProject2/logs/error.log
    CustomLog /Users/UserName/Sites/ExampleProject2/logs/access.log common
    DirectoryIndex index.php
    AllowOverride all
    Order allow,deny
    Allow from all
Climbing Turn logo

Clear understandable advice from Climbing Turn

Give us a call on +44 (0)1438 791010

Let's talk

Other blog items

Picture of Dorothy asking

Your Customers Need to Trust You

First impressions matter

AI UK opening address at the Conversation Stage

AI UK 2024

The AI UK Conference held on the 19th and 20th of March 2024

IT Business owner has just had a great idea

Should you be selling something else?

Victorian Cash Register

Engage your website visitors

What is your number one service or product?

The terminator from the film of the same name

Teaching Ethics to AI

I will be back!

The blockchain visualised as a metaverse of objects

Blockchain Consensus for change

It's More than Just Crypto Currency

AI image created from text: Black stallion creates thunderbolt of business innovation

How AI Benefits Business

5 Business Benefits of AI

Storage at London Drum Company

London Drum Company New Site Launch

Online Drum and Percussion Hire

Cartoon image of a spy

How much do you share?

Privacy at a bus stop

Example of a Google Analytics page

Google Analytics

Image of Desktop and mobile views of site

Introducing BTR International

International move management services

DragonVet Branding

DragonVet: a Hand-crafted Digital Presence

Make your message clear

Images from the How and Why website

How and Why has Launched

A website made to stand out from the crowd

Merlin Logo

Merlin Engine API builder

Get Ready… It’s Almost Here!

Criminal stealing you data

How to prevent Phishing

Phishing is associated with a particular type of nasty fraud.

GDPR

General Data Protection Regulation

This new regulation comes into enforcement on the 25th of May 2018.

Lasting Impressions for Expression Engine v4

Lasting Impressions for ExpressionEngine

Lasting Impressions is ExpressionEngine 4 ready!

Skull and crossbones

Cyber Security

Five tips on how to keep your business safe

Key Performance Indicators

Is Your Website Rubbish?

How to measure its success online

Make your customers happy

Top tips to woo customers

Things that customers love

Customer Satisfaction

Top mistakes that lose you customers

Top 5 mistakes to avoid when publishing on the internet.

EU and British Flags

Is your Web Site Ready for Brexit?

Leaving the EU will bring both threats and opportunities

Whack a Witch

Primary School Children Code HTML

Climbing Turn blog image

Curse of the Brochure Site

Missing the opportunity

Climbing Turn blog image

A Web “Page”

It’s NOT a page!

Climbing Turn blog image

Expression Engine MSM and CartThrob

Using the same channel to sell items on different sites

Climbing Turn blog image

Exceptionally Dull Weirdos

This is a response to Willard Foxton's recent article on the Daily Telegraph blog

Climbing Turn blog image

The Website Machine

What is a website?