I'm trying to set up a simple dev environment with Vagrant. The base box (that I created) has CentOS 6.5 64bit with Apache and MySQL.
The issue is, the httpd service doesn't start on boot after I reload the VM (vagrant reload
or vagrant halt
then up
).
The problem only occurs when I run a provision script that alters the DocumentRoot
and only after the first time I halt the machine.
More info:
httpd is on chkconfig
on levels 2, 3, 4 and 5
There are no errors written to the error_log (on /etc/httpd/logs
).
If I ssh into the machine and start the service manually, it starts with no problem.
I had the same issue with other CentOS boxes (like the chef/centos-6.5
available on vagrantcloud.com), that's why I created one myself.
Other services, like mysql, start fine, so it's a problem specific to apache.
Resuming:
- httpd always start on first boot, even with the provision script (like after vagrant destroy)
- httpd always start when I don't run a provision script (but I need it to set the DocumentRoot)
- httpd doesn't start after first halt, with a provision script that messes with DocumentRoot (not sure if that's the problem).
This is my Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos64_lamp"
config.vm.box_url = "<url>/centos64_lamp.box"
config.vm.hostname = "machine.dev"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder ".", "/vagrant", owner: "root", group: "root"
config.vm.provision :shell, :path => "vagrant_files/bootstrap.sh"
end
I tried to create the vagrant folder with owner/group root
and apache
. Same problem with both (as with owner vagrant
).
These are the provision scripts (bootstrap.sh) that I tried. The only thing that I want them to do is to change the DocumentRoot to the vagrant folder. Neither worked.
Try 1
#!/usr/bin/env bash
sudo rm -rf /var/www/html
sudo ln -fs /vagrant/app/webroot /var/www/html
Try 2
#!/usr/bin/env bash
sudo cp /vagrant/vagrant_files/httpd.conf /etc/httpd/conf
sudo service httpd restart
The httpd.conf on the second try is equal to the default one, except for the DocumentRoot path. This second alternative allows me to do vagrant up --provision
to force the restart of the service, but that should be an unnecessary step.
What else can I try to solve this? Thank you.