unixなんぞだと、rc2.dに起動スクリプトなんぞを置いてとなるのだけど、OSXなので、まずはご本尊 で情報収集。
ここ には/Library/StartupItemsにスクリプトとplistを作成しろとある。
makeの時にお世話になったここ を見ると、面倒だから、Apacheからコピーしてしまえとある。
というわけで、手順はこのようになりました。
まず、標準のApacheの起動スクリプトをコピーする
sudo -s
ditto /System/Library/StartupItems/Apache /Library/StartupItems/Apache2
mv /Library/StartupItems/Apache2/Apache /Library/StartupItems/Apache2/Apache2
Apacheとなっている部分を書き換える
defaults write /Library/StartupItems/Apache2/StartupParameters Provides -array "Apache2"
perl -p -i -e 's/WEBSERVER/APACHE2/g' /Library/StartupItems/Apache2/Apache2
hostconfigに付け足す
echo "APACHE2=-YES-" >> /etc/hostconfig
このままだとパスが違うので、text editorで/Library/StartupItems/Apache2/Apache2を編集する
#!/bin/sh
##
# Apache2 HTTP Server
##
. /etc/rc.common
StartService ()
{
if [ "${APACHE2:=-NO-}" = "-YES-" ]; then
echo "Starting Apache2 web server"
if [ ! -e /usr/local/apache2/conf/httpd.conf ] ; then
cp -p /usr/local/apache2/conf/httpd-std.conf /usr/local/apache2/conf/httpd.conf
fi
/usr/local/apache2/bin/apachectl start
if [ "${WEBPERFCACHESERVER:=-NO-}" = "-YES-" ]; then
if [ -x /usr/sbin/webperfcachectl ]; then
echo "Starting web performance cache server"
/usr/sbin/webperfcachectl start
fi
fi
fi
}
StopService ()
{
if [ -x /usr/sbin/webperfcachectl ]; then
echo "Stopping web performance cache server"
/usr/sbin/webperfcachectl stop
fi
echo "Stopping Apache2 web server"
/usr/local/apache2/bin/apachectl stop
}
RestartService ()
{
if [ "${APACHE2:=-NO-}" = "-YES-" ]; then
echo "Restarting Apache2 web server"
/usr/local/apache2/bin/apachectl restart
if [ "${WEBPERFCACHESERVER:=-NO-}" = "-YES-" ]; then
if [ -x /usr/sbin/webperfcachectl ]; then
echo "Restarting web performance cache server"
/usr/sbin/webperfcachectl restart
fi
fi
else
StopService
fi
}
RunService "$1"
とした。
ついでだったので、plistもProperty List Editorを使って、ApacheからApache2へ書き換えた。
Macを再起動したら、Apache2も起動しておりました。
トラックバックURL↓
http://aij.blog80.fc2.com/tb.php/36-56bebdab