{"id":234,"date":"2014-05-26T11:24:30","date_gmt":"2014-05-26T11:24:30","guid":{"rendered":"https:\/\/www.joetannorella.com\/?p=234"},"modified":"2014-08-24T14:25:18","modified_gmt":"2014-08-24T14:25:18","slug":"set-virtual-hosts-mamp","status":"publish","type":"post","link":"https:\/\/www.joetannorella.com\/set-virtual-hosts-mamp\/","title":{"rendered":"How to set up virtual hosts on MAMP"},"content":{"rendered":"
This is something I found myself Googling every time I needed it. That was until I actually just sat down and \u00a0thought about what it was I was doing when I needed to set up a new local virtual host. This really isn’t difficult at all, but there are some file paths that need remembering. These are:<\/p>\n
Add your chosen domain to your hosts file. Open up Terminal and then type:<\/p>\n
sudo nano -w \/private\/etc\/hosts<\/pre>\nThen add in the following to the bottom of this file (it doesn’t really matter if it’s at the bottom or not, but I generally add new ones to the bottom):<\/p>\n
127.0.0.1 mydomain.dev<\/pre>\nI like to use the “.dev” extension for any ‘local’ domains I set up.<\/p>\n
Step 2<\/strong><\/h2>\n
Navigate over to the following location in Finder:<\/p>\n
\/Applications\/MAMP\/conf\/apache\/<\/pre>\nNow open up Httpd.conf in a text editor. You can do this in nano or vi, but I prefer to just use my favourite text editor (Sublime text!).<\/p>\n
This is where tutorials on this can vary. You can either include a separate dedicated vhosts conf file into the main httpd.conf, OR you can just add your vhosts to the bottom of the httpd.conf file. It really doesn’t matter. From an organisational point of view then it’s probably better to have a separate of concerns and go with the vhosts.conf file (\/extra\/vhosts.conf). If you go this route then make sure you uncomment the vhosts line in your httpd.conf file.<\/p>\n
Anyway, here’s what you need to do. Copy a paste this into the bottom of your httpd.conf file (or vhosts.conf file if that’s what you’d like to use):<\/p>\n
\r\n<VirtualHost *:8888>\r\nServerName mydomain.dev\r\nDocumentRoot \/sites\/mydomain\/public_html\/\r\n\r\nDirectory \/sites\/mydomain\/public_html\/>\r\nOptions Indexes FollowSymLinks MultiViews\r\nAllowOverride All\r\nOrder allow,deny\r\nallow from all\r\n\/Directory>\r\n\/VirtualHost>\r\n<\/pre>\nMake sure your location is correct. I personally have a folder outside of htdocs, whereas many people keep their sites within htdocs. All of my sites can be found at \/sites\/, whereas yours may be at\u00a0\/Applications\/MAMP\/htdocs\/.<\/div>\nStep 3<\/strong><\/h2>\n
Save everything and restart MAMP.<\/div>\nStep 4<\/strong><\/h2>\n
Enjoy your local domain \ud83d\ude42<\/div>\nLet me know if you have any questions – I’m happy to help!<\/div>\n","protected":false},"excerpt":{"rendered":"This is something I found myself Googling every time I needed it. That was until I actually just sat down and \u00a0thought about what it was I was doing when I needed to set up a new local virtual host. This really isn’t difficult at all, but there are some file paths that need remembering….<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"yoast_head":"\n
How to set up virtual hosts on MAMP - JoeTannorella.com<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n