Posts Tagged ‘ silent startup ’

Tutorial: Launching MAMP Silently on Startup

Monday, August 25th, 2008

MAMP Web ServerMAMP is a great tool for running and managing a development server when you require more than the basic PHP configuration included with Leopard. However, getting the web server to run typically involves launching MAMP, entering your root password, and quitting MAMP.

This tutorial walks through the simple steps needed to launch MAMP silently on startup so that you do not have to enter your root password every time.

The issue with MAMP is that launching Apache must be done as root, so there’s no way to simply add MAMP to your startup items via the system’s Accounts Preferences in a way that will launch the app silently. But you don’t need to. Here’s the deal: MAMP’s launcher is just a pretty UI that opens a shell script that, in turn, launches MAMP’s Apache and MySQL servers.

You can set up launch daemons that do the exact same thing without the need to launch MAMP or enter a password.

Step 1: Create the Start-up Items

Open up your favorite text editor and paste the following into an empty document:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>info.mamp.start.apache</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/MAMP/Library/bin/apachectl</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Create another for the MySQL start-up item:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>info.mamp.start.mysql</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/MAMP/Library/bin/mysqld_safe</string>
<string>–port=3306</string>
<string>–socket=/Applications/MAMP/tmp/mysql/mysql.sock</string>
<string>–lower_case_table_names=0</string>
<string>–pid-file=/Applications/MAMP/tmp/mysql/mysql.pid</string>
<string>–log-error=/Applications/MAMP/logs/mysql_error_log</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>YOUR_USERNAME</string>
</dict>
</plist>

Be sure to replace “YOUR_USERNAME” with the username for your account.

Step 2: Save the Files

Save this file as (or move the file to) /Library/LaunchDaemons/info.mamp.start.apache.plist and /Library/LaunchDaemons/info.mamp.start.mysql.plist, respectively.

Step 3: Set Permissions

If you try to launch the daemons at the moment, you’ll get a “dubious permissions” error. To correct this problem, you’ll need to change your permissions.

In your terminal, type:

cd /Library/LaunchDaemons/
sudo chown root:wheel info.mamp.start.apache.plist
sudo chown root:wheel info.mamp.start.mysql.plist

You’re done! Reboot your computer and test that your development server is running as expected by opening a served page in your browser.

Sphere: Related Content