Before I start explaining on how we can change the root directory on Apache Server using MAMP, it’s important to remember that although MAMP was originally designed for Apple MAC systems, there is also a Windows version. I will be explaining how we can change the root directory on Apache server on both cases.
The examples below are for the standard versions of MAMP (free) and not the PRO versions (you have to pay after the trial period has expired).
If you don’t have MAMP yet you can get your free copy from http://www.mamp.info/en/.
MAMP on MAC (method 1)
- Open MAMP
- Select Preferences
- Select Apache
- You will be able to see the current location of your document root
- Click on the object next to the ‘Document Root:‘ text
- You will now have a new Finder window opened
- Select the new location for your document root and click on the ‘Select‘ button
- You have now setup the new document root location
- Select OK
- MAMP automatically stops and starts the Apache and MySQL servers
MAMP on MAC (method 2)
- Using Finder, select your HD device
- Go to Applications > MAMP > conf > apache
- Edit file httpd.conf
- Do a find on ‘DocumentRoot’
- Replace the current path of your DocumentRoot (e.g.: /Applications/MAMP/htdocs) by your new (e.g.: /WebServers).
- Do another find on ‘DocumentRoot’ until you get to the line that says “This should be changed to whatever you set DocumentRoot to.“
- Replace the path on DocumentRoot (e.g.: /Applications/MAMP/htdocs) by your new path (e.g.: /WebServers).
- Save the modified httpd.conf file
- Go to MAMP
- Select Stop Servers (if they are up and running)
- Once the Apache and MySQL servers are stopped, select Start Servers
MAMP on Windows (method 1)
In these instructions I will assume that you’ve installed MAMP on its default location (C:\MAMP). If this is not the case, then you should replace ‘C:\MAMP‘ in the instructions by your own MAMP location.
- Open MAMP
- Select Preferences
- Select Apache
- Click on ‘Select’
- Select where your new document root should be located
- Click on the ‘OK’ button
- Click on the ‘OK’ button
- MAMP automatically stops and starts the Apache and MySQL servers
MAMP on Windows (method 2)
- Using Windows Explorer, select drive C
- Go to C:\MAMP\conf\apache
- Edit file httpd.conf
- Do a find on ‘DocumentRoot’
- Replace the current path of your DocumentRoot (e.g.: C:\MAMP\htdocs) by your new path (e.g.: C:\WebServers).
- Do another find on ‘DocumentRoot’ until you get to the line that says “This should be changed to whatever you set DocumentRoot to.“
- Replace the path on DocumentRoot (e.g.: C:\MAMP\htdocs) by your new path (e.g.: C:\WebServers).
- Save the modified httpd.conf file
- Go to MAMP
- Select Stop Servers (if they are up and running)
- Once the Apache and MySQL servers are stopped, select Start Servers
Thank you so much, I was wasting my head and time because I can’t set up any site on my localhost, and I have to start a wordpress course for my job. You literally helped me a lot. God bless you. PS. Excuse my English, Greetings from Colombia.
Thank you for sharing!
Thanks!