Linux – Apache not automatically starting after a reboot of a Scientific Linux Vagrant Box

apache-2.2linuxsshvagrantweb

Every time I reboot my Scientific Linux box, I have the problem that it is
not starting the Apache Web Server (httpd).

I have to do it manually with this code:

[vagrant@magento ~]$ sudo service httpd restart
Stopping httpd:                                            [FAILED]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]

I have a similar setup on a Vagrant box with Ubuntu 12.04 Server which started the httpd services properly, so what's the clue of getting a Scientific Linux Apache server booting the httpd automatically?

Every time I use the command: vagrant reload in my command prompt, the web server doesn't get the httpd service up and I have to use the restart command (sudo service httpd restart) to get it. But I want that function automatically like on my Ubuntu 12.04 before (precise64). So the decisive factor is not the line between the Failed and OK message, the problem is that it is on status FAILED after a reboot.

Update: tried your nice idea instant! But I determine, that all 3 run levels (3,4,5) are already on status ON. This is my current status:

   34  [vagrant@example ~]$ chkconfig --list
   35  crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
   36  htcacheclean    0:off   1:off   2:off   3:off   4:off   5:off   6:off
   37  httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
   38  ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
   39  iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
   40  lvm2-monitor    0:off   1:on    2:on    3:on    4:on    5:on    6:off
   41  mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
   42  netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
   43  netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
   44  network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
   45  postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
   46  rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
   47  rsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:off
   48  saslauthd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
   49  sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
   50  udev-post       0:off   1:on    2:on    3:on    4:on    5:on    6:off
   51  vboxadd         0:off   1:off   2:on    3:on    4:on    5:on    6:off
   52  vboxadd-service 0:off   1:off   2:on    3:on    4:on    5:on    6:off
   53  vboxadd-x11     0:off   1:off   2:off   3:on    4:off   5:on    6:off
   54  [vagrant@magento ~]$ chkconfig --list | egrep '(apache|httpd)'
   55  httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Best Answer

We have the same problem. For us, it is caused by Apache relying on shared files that are mounted by Vagrant. This causes Apache to fail during loading.

In previous versions of Vagrant, the provisioning scripts were always run on boot/reboot, so Apache would be restarted after the network shares were attached.