44453

mac添加自启动服务(nginx、php)

乐果   发表于   2015 年 06 月 05 日 标签:macmysqlPHP

接着上次的mac下编译安装nginx、php,现在来将它们设置为开机自启动。

一、添加nginx开机自启动

vim /Library/LaunchDaemons/nginx.plist

编辑,添加如下内容(注意,上次编译安装nginx时,目录为data/service/nginx):

<?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>nginx</string>
                <key>Program</key>
                <string>/data/service/nginx/sbin/nginx</string>
                <key>KeepAlive</key>
                <true/>
                <key>NetworkState</key>
                <true/>
                <key>StandardErrorPath</key>
                <string>/var/log/system.log</string>
                <key>LaunchOnlyOnce</key>
                <true/>
        </dict>
</plist>

二、添加php开机自启动

vim /Library/LaunchDaemons/php54.plist

编辑,添加如下内容(注意,上次编译安装php时,目录为data/service/php54):

<?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>php54</string>
                <key>Program</key>
                <string>/data/service/php54/sbin/php-fpm</string>
                <key>RunAtLoad</key>
                <true/>
        </dict>
</plist>

三、重启机器

重启前,网上说如下操作,但我没操作如下,重启貌似也不影响,我暂时对launchctl load命令不了解:

//加入系统启动  
sudo launchctl load -w  /Library/LaunchDaemons/nginx.plist   
//启动服务 
sudo launchctl load  /Library/LaunchDaemons/nginx.plist 

乐果   发表于   2015 年 06 月 05 日 标签:macmysqlPHP

1

文章评论

回复

DoraEvack

04 月 09 日 18 时 55 分

hi!