Mamp

MAMP Setup on OSX

Setting up macOS with Apache, MySQL and PHP.

The guide uses the default Mac OSX Apache and PHP along with Homebrew for installing MySQL.

Apache

Open the Apache server configuration file httpd.conf for editing

/private/etc/apache2/httpd.conf

httpd.conf settings

Set the server name to localhost

ServerName localhost:80

Configure document root for sites folder (create ~/Sites if needed)

DocumentRoot "/Users/<user-name>/Sites"
<Directory "/Users/<user-name>/Sites">

Set log file location and create folder if needed

ErrorLog "/private/var/log/apache2/error_log"
CustomLog "/private/var/log/apache2/access_log" common

Enable the PHP module (add or uncomment)

Expand directory index file extensions (not required when other/php7.conf is used)

Enable the virtual hosts configuration file (add or uncomment)

Virtual hosts

Edit Apache vhosts configuration file

Remove sample configs and add new vhost

Start Apache

Start (or restart) Apache to activate new config

PHP

Create a php.ini file

(For additional error reporting when developing, download the related distribution from php.net/releases and use php.ini-development contents for php.ini config)

Add your timezone to date.timezone to stop PHP date warning (eg. America/Los_Angeles)

Configure MySQL socket setting, find and set the following

Hosts File

Open the etc hosts file

Add entries for each virtual host

MySQL

Install MySQL with Homebrew (Latest: msyql or Version: [email protected])

And MySQL bin folder to path (reload shell to activate)

Start MySQL server

Secure MySQL installation

Step through MySQL secure installation procedure

  • Set a root password

  • Remove anonymous user

  • Disallow root login remotely

  • Remove test databases

  • Reload privileges

General Information

Useful Files and Directories

Default user sites location

Base Apache files location

Default Apache page (contains default index page)

Location of MySQL database files

Last updated