If you have a local production environment with MAMP you know how annoying is to start MAMP every time, type your password and have it running as another open application with a window and dock icon. To solve this you can make a little script that will open MAMP each time you log on to your account without requiring a password and keep it running invisible in the background.
1.- First open the Keychain Access application that is found in the Utilities folder within the Applications folder.
2.- Add a new element called MAMP with your session account and password and save it:
3.- Now open AppleScript Editor found in the same directory as the previous application, there you’re going to copy and paste this code:
on run set theUserName to do shell script ("security find-generic-password -gl MAMP | grep \"acct\" | cut -c 19-99 | sed 's/\"//g'") set thePassword to do shell script ("security 2>&1 >/dev/null find-generic-password -gl MAMP | cut -c 11-99 | sed 's/\"//g'") do shell script "/Applications/MAMP/bin/startApache.sh &" password thePassword user name theUserName with administrator privileges do shell script "/Applications/MAMP/bin/startMysql.sh > /dev/null 2>&1" end run
Basically this script starts the MAMP server using your password in the Keychain Access app.
4.- Now save the script as an application and name it something like “openMAMP”.
5.- Move your application to the Applications folder and add it to your login items by entering to your account settings in the system preferences, this way the script will run every time you log on:
6.- Finally restart your computer. It is assumed that after the restart when logging to your session the script will run and it will start your local server. There will be no application running but the server will be running.