技術メモのかけら

内容はもとより調べたことすら忘れてしまうので個人的なメモです。とにかく短く、結論だけ書いていきます。

ubuntuでapache自動起動設定

  • apachectlをinit.dへコピー
$ sudo install -o root -g root -m 755 /usr/local/apache2/bin/apachectl /etc/init.d/apache
  • update-rc.dで展開。なんか警告が出ているが、とりあえず無視。
$ sudo update-rc.d apache defaults 85 15
update-rc.d: warning: /etc/init.d/apache missing LSB information
update-rc.d: see http://wiki.debian.org/lsbinitscripts
 Adding system startup for /etc/init.d/apache ...
   /etc/rc0.d/K15apache -> ../init.d/apache
   /etc/rc1.d/K15apache -> ../init.d/apache
   /etc/rc6.d/K15apache -> ../init.d/apache
   /etc/rc2.d/S85apache -> ../init.d/apache
   /etc/rc3.d/S85apache -> ../init.d/apache
   /etc/rc4.d/S85apache -> ../init.d/apache
   /etc/rc5.d/S85apache -> ../init.d/apache

  • lsで見てみるとinit.dへリンクが張られている
$ ls -al rc*|grep apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 K15apache -> ../init.d/apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 K15apache -> ../init.d/apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 S85apache -> ../init.d/apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 S85apache -> ../init.d/apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 S85apache -> ../init.d/apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 S85apache -> ../init.d/apache
lrwxrwxrwx   1 root root    16 2011-12-07 23:56 K15apache -> ../init.d/apache
  • 再起動後に起動確認。ちゃんと起動した。
$ ps -fe|grep httpd
root      1009     1  0 00:02 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    1036  1009  0 00:02 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    1037  1009  0 00:02 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    1038  1009  0 00:02 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    1039  1009  0 00:02 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    1040  1009  0 00:02 ?        00:00:00 /usr/local/apache2/bin/httpd -k start