Tag Archives: mamp

How to make MAMP include your local VirtualHosts

If you, like me, like to define your own VirtualHosts, and don’t like re-defining them every time you upgrade MAMP, there’s a solution. Store your virtual hosts in a separate place, and then just include them in the MAMP httpd.conf. Since Macs have Apache built in, I store all my custom VirtualHosts in:

/private/etc/apache2/extra/httpd-vhosts.conf

Edit MAMP’s apache configuration file located at:

/Applications/MAMP/conf/apache/httpd.conf

..And append the following line at the end:

Include /private/etc/apache2/extra/httpd-vhosts.conf

Then restart MAMP, and you’re done!

MAMP 1.8.3 with VirtualHostX

MAMP and VirtualHostX make for an easy PHP development platform for your Mac.  Both are compatible with Mac OS X 10.6 (Snow Leopard). Even though they are both simple to install and integrate, there are still some things you have to fix to make it work.

1. Turn off your Web Sharing in Applications > System Preferences > Sharing.  Make sure the box is not checked next to ‘Web Sharing’.

2. Install MAMP and VirtualHostX

3. Run VirtualHostX’s Setup Wizard

It’s a 2 step process. First, Backup your existing VirtualHostX settings (if you have them). Second, click the Make Changes button. This will allow the built-in Apache server and the MAMP Apache server share a virtual hosts file.  It also will change MAMP to run off of port 80.

VirtualHostX Setup Wizard

4. Configure VirtualHostX

Set VirtualHostX to use MAMP as the default web server.  This makes the “Apply” button in VirtualHostX

VirtualHostX Preferences with MAMP

5. Configure MAMP

Open up the preferences in MAMP, click on the “Ports” tab, and click “Set to default Apache and MySQL ports.” Then click “OK.”

MAMP preferences

6. Fix the phpMyAdmin

VirtualHostX hasn’t updated it’s configuration to work with the latest MAMP.  So, when you run the Setup Wizard, it replaces a section of the Apache configuration with an incorrect configuration. Open /Applications/MAMP/conf/apache/httpd.conf in TextEdit, and replace this block:

Alias /phpMyAdmin "/Applications/MAMP/bin/phpMyAdmin"

<Directory "/Applications/MAMP/bin/phpMyAdmin">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

With this block

Alias /phpMyAdminForPHP4 "/Applications/MAMP/bin/phpMyAdminForPHP4"

<Directory "/Applications/MAMP/bin/phpMyAdminForPHP4">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Alias /phpMyAdminForPHP5 "/Applications/MAMP/bin/phpMyAdminForPHP5"

<Directory "/Applications/MAMP/bin/phpMyAdminForPHP5">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

7. Restart your MAMP servers (stop then start), and you should be good.

8. Add hosts in VirtualHostX

Click the “Add Host” button, enter the domain name and Local Path, make sure the Port is set at 80, then click “Apply Changes.”

VirtualHostX "Add Host"

Now simply navigate to “http://testsite/” in your web browser, and you’ll see your test site.

Happy MAMP-ing!