How to start MAMP on port 80 without a password

I’m a big fan of MAMP. It’s the fastest way for anyone to get set up with a local PHP/MySQL development environment on a mac. One of the small annoyances with MAMP is that it requires you to enter your password all the time if you want to run it on port 80 (which I do). To be fair, it’s got more to do with UNIX security than MAMP… but it’s still bloody annoying!

I tried Steve Stringer’s technique of using launch daemons, but it just couldn’t get it to work for me.

The trick to getting MAMP to start behind the scenes is knowing that all that pretty GUI does is call a couple shell scripts. Specifically, those scripts are /Applications/MAMP/bin/startApache.sh and /Applications/MAMP/bin/startMysql.sh (assuming you installed MAMP at the default location).

The second thing you should know is that startApache.sh must be run as root, but startMysql.sh must be run as the current user. I created a new shell script to call those scripts appropriately:

sudo /Applications/MAMP/bin/startApache.sh
/Applications/MAMP/bin/startMysql.sh
exit 0

I then added added an exception for that script to my sudoers file so I didn’t need to enter a password when I used sudo. The easiest way to add this exception is to use the ‘visudo’ command as root.

Finally, I used Automator to wrap the whole thing up as an application I could add to my dock. It works! One less daily annoyance in my life!

Since writing this, Damian Gaweda has posted a more elegant solution that’s worth checking out.
  • This all goes a little over my head.

    Is there any way you can explain in a bit more details how to go about setting this up please? I'm afraid I'm never going to be able to get from your explanation, to writing the script, to linking it all up to Automator.

  • What a lucky find! The MAMP login has been bugging me for the longest time! Thanks a trillion-fold.

    When I run your script (with the visudo override in place), MAMP does, indeed, start up but the terminal displays this message before starting the mysqld daemon:

    chown: /Applications/MAMP/logs/mysql_error_log: Operation not permitted

    Do you have any idea what it means? Is it important or can I just ignore it?

    • That error suggests that the user you're running it under is unable to write to that file. It sounds like you need to change the permissions for that log file.

      • Thanks Josh – DUH!

        Is there an equivalent method for shutting MAMP down (as it also requires the login prompt).

        BTW: I attempted to write an Automator action but although it DOES start MAMP, it also runs forever. I never use Automator so it is most likely something I am doing wrong – I did a net lookup on running shell scripts with Automator and they talk about writing Cocoa apps for it which seems an awful lot of bother for a one line script. Ho-hum!

        • I've not tested this, but I think this would work:

          sudo /Applications/MAMP/bin/stopApache.sh
          /Applications/MAMP/bin/stopMysql.sh
          exit 0

          I have that same issue with the automator appearing to run forever, although I'm not sure that it actually is doing anything. I just close it out if it starts to bug me. I'd love to hear if you figure out a solution for that.

          • I've put together an app that allows you to start/stop MAMP's Apache and MySQL without the password request, even on port 80. It stores the password in Keychain, so you only need to enter it once. It has a nice icon too!

            Download: http://www.46palermo.com/blog/run-mamp-without-pa

          • Very nice. Thanks for letting me know about it. I've added a note to my post linking to your app.

  • I've not tested this, but I think this would work:

    sudo /Applications/MAMP/bin/stopApache.sh
    /Applications/MAMP/bin/stopMysql.sh
    exit 0

    I have that same issue with the automator appearing to run forever, although I'm not sure that it actually is doing anything. I just close it out if it starts to bug me. But let me know if you figure out a solution for that.

  • bberg

    hello. ok, created an app in automator using the "run shell script" action. added the app to my sudoers file successfully. the only problem is that when i run the app, it justs reads "workflow running" at the top menu. it gets stuck. any ideas? thanks

    • Other people have reported having the same issue. I'm not sure why it doesn't exit as expected. If you figure it out, please let me know so I can share with my other readers.

    • It appears that this issue has been resolved in Snow Leopard.

  • Good information, but how is it without the password?