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