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!

8 thoughts on “MAMP 1.8.3 with VirtualHostX

  1. How do you access phpmyadmin? I’m using MAMP 1.9 and VHX 2.4.1 and it looks like the solution you have detailed here is in place by default. My virtual hosts work perfectly though I can not access phpmyadmin from the MAMP localhost/MAMP or from my virtual host foo.site.com/phpmyadmin/

    Any ideas?

  2. I just upgraded to MAMP 1.9, and it seems that the phpMyAdmin has broken. I’ll have a heart-to-heart sometime in the next couple of days and get back to you.

  3. There is a small error above in #6. Instead of “replacing” that block, you simply add to it. If the first block isn’t there, then you have found your problem . . . You NEED that block.

    To put it simply, it should look like this:
    ======================================
    Alias /phpMyAdmin “/Applications/MAMP/bin/phpMyAdmin”

    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

    Alias /phpMyAdminForPHP4 “/Applications/MAMP/bin/phpMyAdminForPHP4”

    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

    Alias /phpMyAdminForPHP5 “/Applications/MAMP/bin/phpMyAdminForPHP5”

    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

    ======================================
    Notice that ALL of the blocks are included, none replaced. In fact, you really only need the first block, but the other blocks make it upgrade friendly.

    If you do this and restart your server, all should be well.

    Hope this saves someone some frustration.

    Clifton

  4. @Clifton
    Fixed! Thank you.

    Anyone know why I have to login each time I stop/restart MAMP?

  5. Any time you start a service that listens to network traffic, in this case, both Apache and MySQL are listening to traffic, you have to give you credentials. This prevents unwanted processes, such as viruses, to use the network.

  6. I just got mine to work. Strange how things take low priority until you actually need them :)

    Here’s what I ended up with. This is the only block I needed: (The others broke apache)

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

    Works like a charm!

Leave a Reply

Your email address will not be published. Required fields are marked *