Apache / httpd not starting automatically on boot

I have apache2 installed on Amazon Linux AMI release 2012.03. I'm able to start it manually just fine, without any errors using /etc/init.d/httpd start. However, it doesn't start automatically when the machine is booted up.

It appears that everything is configured properly in my rc*.d directories. Here's the result of find /etc/rc.d -name "*httpd*" | xargs ls -l:

-rwxr-xr-x 1 root root 3371 Feb 16  2012 /etc/rc.d/init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc0.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc1.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc2.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc3.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc4.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc5.d/K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root   15 Apr 14  2012 /etc/rc.d/rc6.d/K15httpd -> ../init.d/httpd

I understand that I can put the /etc/init.d/httpd start command into /etc/rc.local, but isn't that a workaround? Why isn't it starting automatically? Other stuff in the rc*.d directories starts just fine on bootup (mongod, postfix, etc). Thanks!


Solution 1:

Use chkconfig to manage the runlevels under which you want this service to start.

Usually chkconfig httpd on does the job.

Solution 2:

You do not have any "S" links. All the "K" are shutdown only. Add links with same name, just replace the K with S.

"In general, the system starts commands that begin with the letter "S" and stops commands that begin with the letter "K." Commands that begin with the letter "K" run only when the system is changing run levels from a higher to a lower level. Commands that begin with the letter "S" run in all cases."

If using chkconfig, see "man chkconfig". For your case:

chkconfig --level 2345 httpd on

should do.