mac開機啟動apache、memcached與mysql

來源:互聯網
上載者:User

標籤:

一、開機自動啟動apache方法

#sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist //開機啟動#sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist //關閉啟動

二、開機自啟動memcached方法

      centos下設定開機自啟動某個服務,只需要把啟動服務對於的命令添加到/etc/rc.local檔案中即可,例如開機自動啟動memcached,在檔案中加入如下資訊即可:

/usr/local/memcached/bin/memcached -d -m 64 -l 127.0.0.1 -p 11211 -u root

mac os lion 中似乎沒有這個檔案,如果要做到開機自啟動,則需要通過plist指令碼來完成,關於plist指令碼的更多資訊可以參考:mac os 定期任務配置。

以自啟動memcached為例,首先寫一個啟動memcached的shell指令碼,命名為start-memcached,存放在/usr/bin下,當然檔案名稱、存放路徑可以隨意按自己喜歡方式來命名,shell指令碼的內容為:

#!/bin/bash/usr/bin/memcached -d -m 16 -l 127.0.0.1 -p 11211 -u phpdragon

注意該檔案要有執行許可權,可以使用chmod命令修改,memcached命令根據本機實際路徑來書寫。

在plist指令碼中來執行上述shell指令碼,plist指令碼命名為:com.phpdragon.memcached.plist,存放在/Library/LaunchDaemons下,指令碼內容如下:

<?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>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>

通過上述配置,每次開機後都會自動啟動memcached服務了。

 

三、開機自動啟動mysql方法(dmg方式安裝)

1.添加檔案

代碼如下:
touch  /Library/LaunchDaemons/com.sun.mysqld.plist

 

2.新增內容

代碼如下:
<?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.添加後重啟

代碼如下:
sudo launchctl load -w /Library/LaunchDaemons/com.sun.mysqld.plist

mac開機啟動apache、memcached與mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.