MAMP

Site management

Apache config

Add a unique entry for each site:

File: /Applications/MAMP/conf/apache/httpd.conf

# -----------------------------------------------
# GravDept:
# Custom virtual hosts
# -----------------------------------------------

<VirtualHost *>
    ServerName example.dev
    DocumentRoot "/Users/brendan/work/projects/example/www"

    <Directory "/Users/brendan/work/projects/example/www">
        Options FollowSymLinks Indexes Multiviews
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost *>
    ServerName test.dev
    DocumentRoot "/Users/brendan/work/projects/test/www"

    <Directory "/Users/brendan/work/projects/test/www">
        Options FollowSymLinks Indexes Multiviews
        AllowOverride All
    </Directory>
</VirtualHost>

Hosts config

Edit your Mac’s hosts file:

sudo nano /etc/hosts
# MAMP
127.0.0.1 example.dev
127.0.0.1 test.dev

Database management

Import / export

# Import database from file
/Applications/MAMP/Library/bin/mysql -u [DB_USER] -p [DB_NAME] < data.sql

# Export database to file
/Applications/MAMP/Library/bin/mysqldump -u [DB_USER] -p [DB_NAME] > data.sql

# Log into mysql
# Password: root
/Applications/MAMP/Library/bin/mysql -u root -p

# Run queries
create database learningLaravel;
show databases;

Reference

Assign existing user to imported database

In phpMyAdmin:

  1. Click Home icon.
  2. Click User accounts tab.
  3. Click Edit privileges link for the user.
  4. Click Database tab.
  5. Select the database from the multi-select input.
  6. Check all privileges.
  7. Click Go.

Assign global priveliges to a user

Sometimes importing a database requires global priveliges. I’m not sure why, but I don’t worry about it for a local environment.

In phpMyAdmin:

  1. Click Home icon.
  2. Click User accounts tab.
  3. Click Edit privileges link for the user.
  4. The Global tab is selected (default view).
  5. Check all privileges.
  6. Click Go.

Preferences

Apache port 80
Nginx port 7888
MySQL port 3306
PHP version 5.6.27
PHP cache Off
Web server Apache

Configuration

Apache config

# Edit this file:
# /Applications/MAMP/conf/apache/httpd.conf


# -----------------------------------------------
# GravDept:
# Enable GZIP
# -----------------------------------------------

<IfModule mod_deflate.c>
    # Compress HTML, CSS, JavaScript, Text, XML and fonts
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml

    # Remove browser bugs (only needed for really old browsers)
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
</IfModule>


# -----------------------------------------------
# GravDept:
# Custom virtual hosts
# -----------------------------------------------

# Add vhosts here

MySQL config

File: /Applications/MAMP/conf/my.cnf

phpMyAdmin config

Something broke related to the MySQL root user’s password, and this is necessary now:

File: /Applications/MAMP/bin/phpMyAdmin/config.inc.php

// Leave these alone:
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user']      = 'root';

// Make sure this is 'root':
$cfg['Servers'][$i]['password'] = 'root';

// Add this line:
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = false;

Otherwise you won’t be able to access phpMyAdmin.

PHP config

File: /Applications/MAMP/bin/php/php5.5.3/conf/php.ini

memory_limit = 128M

Note: you may need to raise to 256M if Magento returns white pages.

Error logs

/Applications/MAMP/logs/apache_error.log
/Applications/MAMP/logs/mysql_error_log.err
/Applications/MAMP/logs/php_error.log

Tricks

  • Disable OPcache if PHP pages don’t refresh. Reference