First, the boot automatically start Apache method
#sudo launchctl load-w// boot up #sudo launchctl unload-w// Turn off startup
Second, boot self-starting memcached method
Under CentOS Setup boot a service, only need to add the command of the start service to the/etc/rc.local file, for example, boot automatically start memcached, add the following information in the file:
/usr/local/memcached/bin/memcached-d-M 64-l 127.0.0.1-p 11211-u Root
There seems to be no such file in Mac OS Lion, and if you want to boot up, you need to do it through the plist script, more information about the plist script can be found in: Mac OS periodic task configuration.
To start memcached as an example, first write a shell script to start memcached, named Start-memcached, stored under/usr/bin, of course, the file name, storage path can be arbitrary according to their favorite way to name, shell script content is:
#!/bin/bash127.0. 0.1 11211 -u phpdragon
Note that the file has execute permissions and can be modified with the chmod command, and the memcached command is written according to the native actual path.
In the plist script to execute the above shell script, plist script named: com.phpdragon.memcached.plist, stored under/library/launchdaemons, the script content is as follows:
<?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 "><plistversion= "1.0"><Dict> <Key>Label</Key> <string>Com.phpdragon.memcached.plist</string> <Key>Programarguments</Key> <Array> <string>/usr/bin/start-memcached</string> </Array> <Key>KeepAlive</Key> <false/> <Key>Runatload</Key> <true/> <Key>Standarderrorpath</Key> <string>/tmp/memcached.err</string> <Key>Standardoutpath</Key> <string>/tmp/memcached.out</string></Dict></plist>
With the above configuration, the Memcached service will start automatically after each boot.
Third, the boot automatically start the MySQL method (DMG mode installation)
1. Add Files
The code is as follows:
Touch /library/launchdaemons/com.sun.mysqld.plist
2. Add Content
The code is as follows:
<?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>KeepAlive</key> <true/> <key> label</key> <string>com.sun.mysqld</string> <key>ProgramArguments</key> <array> <string>/usr/local/mysql/bin/mysqld_safe</string> <string>--user =root</string> </array> </dict> </plist>
3. Restart after adding
The code is as follows:
sudo launchctl load-w/library/launchdaemons/com.sun.mysqld.plist
Mac boot up Apache, memcached and MySQL