Note: I recommend using Vagrant/Homestead instead of MAMP these days.
Simple bash script to add entry to vhosts and hosts file for local web environments like MAMP.
-
Open up vhosts.sh in a text editor to check configuration.
-
Check
web_root_path
is path to local web root. Example: /Users/name/Sites/ -
Check
vhost_path
is correct path to your vhosts file. Example: /Applications/MAMP/conf/apache/vhosts.conf -
Check
apache_restart
contains correct path toapachectl
. Example: "/Applications/MAMP/bin/apache2/bin/apachectl restart -
Check
apache_port
is the correct port for apache. Default: 8888 -
Verify vhosts block contains correct configuration (line 58)
Run as root: sudo sh vhosts.sh
-
Enter desired local domain. Example: newproject.local
-
Enter desired directory new local domain points to. Example: newproject
-
Test new local domain in browser. Example: http://newproject.local:8888/