Vagrant - start apache at boot

Viewed 6083

I have just create a new box (based on ubuntu precise32) with my own software to install and everything works great eccept apache that do not start at boot.

After the vagrant up I have to log into my box and start it every time.

I have tried to make it start at boot with:

sudo update-rc.d apache2 defaults

but I get:

System start/stop links for /etc/init.d/apache2 already exist.

So it should start... This is my Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    config.vm.define :stilogo do |stilogo_config|
        stilogo_config.vm.box = "precise32"
        stilogo_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
        stilogo_config.ssh.forward_agent = true

        #Do alla macchina un IP statico
        #stilogo_config.vm.network :private_network, ip: "192.168.56.101"

        stilogo_config.vm.network :forwarded_port, guest: 80, host: 8888, auto_correct: true
        stilogo_config.vm.network :forwarded_port, guest: 3306, host: 8889, auto_correct: true
        stilogo_config.vm.network :forwarded_port, guest: 5432, host: 5433, auto_correct: true
        stilogo_config.vm.hostname = "stilogo"
        stilogo_config.vm.synced_folder "www", "/var/www", {:mount_options => ['dmode=777','fmode=777']}
        stilogo_config.vm.provision :shell, :inline => "echo \"Europe/Rome\" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata"

        stilogo_config.vm.provider :virtualbox do |v|
            v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
            v.customize ["modifyvm", :id, "--memory", "512"]
        end

        #Installo il software che mi serve
        stilogo_config.vm.provision :puppet do |puppet|
            puppet.manifests_path = "puppet/manifests"
            puppet.manifest_file = "phpbase.pp"
            puppet.module_path = "puppet/modules"
            #puppet.options = "--verbose --debug"
        end
    end
end

and this the apache installation:

class apache 
{      
    package 
    { 
        "apache2":
            ensure  => present,
            require => [Exec['apt-get update'], Package['php5'], Package['php5-dev'], Package['php5-cli']]
    }

    service 
    { 
        "apache2":
            ensure      => running,
            enable      => true,
            require     => Package['apache2'],
            subscribe   => [
                File["/etc/apache2/mods-enabled/rewrite.load"],
                File["/etc/apache2/sites-available/000-default.conf"],
                File["/etc/apache2/conf-enabled/phpmyadmin.conf"]
            ],
    }

    file 
    { 
        "/etc/apache2/mods-enabled/rewrite.load":
            ensure  => link,
            target  => "/etc/apache2/mods-available/rewrite.load",
            require => Package['apache2'],
    }

    file 
    { 
        "/etc/apache2/sites-available/000-default.conf":
            ensure  => present,
            owner => root, group => root,
            source  => "/vagrant/puppet/templates/vhost",
            require => Package['apache2'],
    }

    exec 
    { 
        'echo "ServerName localhost" | sudo tee /etc/apache2/conf-enabled/fqdn.conf':
            require => Package['apache2'],
    }
}

This is the log after the vagrant up and the (manual) apache start

[Fri Dec 27 15:26:33.220448 2013] [mpm_prefork:notice] [pid 1379] AH00169: caught SIGTERM, shutting down
PHP Warning:  Module 'memcached' already loaded in Unknown on line 0
[Fri Dec 27 15:27:55.750639 2013] [mpm_prefork:notice] [pid 1105] AH00163: Apache/2.4.6 (Ubuntu) PHP/5.5.7-1+sury.org~precise+1 configured -- resuming normal operations
[Fri Dec 27 15:27:55.750700 2013] [core:notice] [pid 1105] AH00094: Command line: '/usr/sbin/apache2'

what am I missing?

4 Answers
Related