Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

migrated from stackoverflow.com Jul 18 '13 at 15:30

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

Given the sound of it, the problem is that Apache is not "on" by default after you do "vagrant reload." I believe "vagrant reload" simulates what would happen if you "power-cycled" the virtual machine. It sounds like you would want to have the Apache daemon to be running after the virtual machine boots.

I went to the Scientific Linux website. It states that the underlying distribution is based on "Enterprise Linux." I would normally interpret this to be "RedHat Enterprise Linux." If this is incorrect, let me know.

The way to turn services on/off based on the runlevel of the operating system is usually handled via "chkconfig." I would first confirm what services are on and off.

chkconfig --list 

You should get a ton of output that has lines that appear as so:

gpm    0:off 1:off 2:off 3:off 4:off 5:off 6:off

The first column is the name of the service and then the subsequent column contain pairs of values that are <runlevel>:<on|off>. So, in the above line, the gpm service is off at all runlevels.

If I were you, I would filter the output and look for "httpd" or "apache" amongst the list of services:

chkconfig --list | egrep '(apache|httpd)'

On my RHEL box I get the following:

httpd   0:off 1:off 2:off 3:off 4:off 5:off 6:off

The default runlevel is usually number "3". I would then cut this service "on" for this run levels 3, 4, and 5 as so:

chkconfig --level 345 httpd on

Even though this is done, you would still need to restart the service manually if it was off when you brought up the VM:

service httpd start

The ServerName directive warning may be ignored, but you will end up having to manually specify the IP address you specified for the VM when it was provisioned, if you want to actually see the web content the VM is providing. I would consult the "Private Networking" section of the Vagrant documentation.

Hope this helps!

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.