Hosting multiple sites on MAMP

I’m currently hosting my OwnCloud instance on my MacBook Air that is running 24/7 at home connected to external drives (http://jaecloud.com) so I can backup my personal files from my iPhone. I’ve also started doing some development work for side projects I’m working on and wanted to host a test server where I could run cron jobs and have unlimited storage.

So I reused a domain name I had registered and pointed it to my home server. I thought it would be as simple as putting in some new variables into the .conf file, but I ran into some difficulties and was discouraged at all the posts on the internet spewing the same information, I saw at least 10 posts that had the SAME EXACT information.

So I decided to make my own post to highlight the issues I ran into and how I solved them.

1) Edit the httpd.conf file in MAMP – the file should be located in /Applications/MAMP/conf/Apache/. I opened the file and found the section that read;

# Virtual hosts
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

And removed the “#” before the Include to enable this feature.

2) Edit the httpd-vhosts.conf file – the file should be located in /Applications/MAMP/conf/apache/extra/. I removed the “#” from the following line;

#NameVirtualHost *:80

The file contained 2 sample <VirtualHost> entries, so I uncommented them and reused them.

<VirtualHost *:80>
ServerAdmin admin@jaecloud.com
DocumentRoot "/Applications/MAMP/htdocs/"
ServerName jaecloud.com
ServerAlias www.jaecloud.com
<Directory "/Applications/MAMP/htdocs/">
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
</VirtualHost>

<VirtualHost*:80>
ServerAdmin admin@jaepaik.me
DocumentRoot "/Applications/MAMP/jaepaikme/"
ServerName jaepaik.me
ServerAlias www.jaepaik.me
<Directory "/Applications/MAMP/jaepaikme/">
</Directory>
</VirtualHost>

3) Change the ports on MAMP to the default ports instead of the local ports that are used. The default port for Apache should be 80 and the default for MySQL should be 3306.

4) Save both the httpd.conf and the httpd-vhosts.conf file and restart both the Apache Server and the MySQL Server.

Now, your MAMP instance should be serving both websites. You can put in some test files into the document root and try to access them via the browser.

Hope this helps someone that was in the same situation as I was last night.