我刚刚创建了一个新的盒子(基于ubuntu precise32
),我自己的软件可以安装,并且一切都很好用,不会在启动时启动apache.
在vagrant up
我必须登录我的盒子并且每次都启动它之后.
我试图让它在启动时启动:
sudo update-rc.d apache2 defaults
但我得到:
System start/stop links for /etc/init.d/apache2 already exist.
所以它应该开始......这是我的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
这个apache安装:
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'], } }
这是vagrant u
p 后的日志和(手动)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'
我错过了什么?
我的期望是你的apache配置以某种方式引用vagrant安装的文件夹中的文件(在/vagrant
dir或定义的文件夹中config.vm.synced_folder
).在启动时,这些文件夹尚不可访问,因为vagrant 在启动计算机后安装它们.
我在这里问了类似的问题:Apache无法在Vagrant上启动.如果是这样,那么也许我在那里得到了答案.