12

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!

2
  • Mike, I think you can use chkconfig --list and chkconfig on with the Amazon AMI distro.
    – JasonAzze
    Jan 24, 2013 at 19:00
  • chkconfig --list shows httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off ... so how do I turn them on? Thanks! Jan 24, 2013 at 19:06

2 Answers 2

36

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

Usually chkconfig httpd on does the job.

6
  • What if that doesn't work? Oct 20, 2015 at 22:41
  • 2
    @PaulSheldrake are you running an OS that uses systemd by any chance? For example, Linuxes in the Red Hat 7 family now use systemd. In that case you want systemctl enable httpd
    – JasonAzze
    Oct 23, 2015 at 22:22
  • @JasonAzze I'm using centos 6.5. Oct 24, 2015 at 1:56
  • @JasonAzze If you're interested in taking a look github.com/paulsheldrake/vagrant/blob/master/scripts/… Oct 26, 2015 at 17:44
  • @PaulSheldrake what is the failure mode? If you issue chkconfig --list httpd is it "on" for runlevels 2-5? I wonder if httpd is trying to start but immediately stopping because of a bad httpd config. Is there evidence in the logs?
    – JasonAzze
    Oct 26, 2015 at 18:10
7

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .