Apache的流浪重装后无法启动 [英] Apache doesn't start after Vagrant reload
问题描述
我试图建立与放浪一个简单的开发环境。基箱(即我创建的)有CentOS的6.5与64位Apache和MySQL。
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.
问题是,httpd服务不启动开机我重装后VM(流浪汉重装
或流浪汉停止
然后最高
)。
The issue is, the httpd service doesn't start on boot after I reload the VM (vagrant reload
or vagrant halt
then up
).
当我运行改变了的DocumentRoot
,只有第一次后,我停止机器。
The problem only occurs when I run a provision script that alters the DocumentRoot
and only after the first time I halt the machine.
httpd的是的chkconfig
上水平2,3,4和5
httpd is on chkconfig
on levels 2, 3, 4 and 5
有没有写入error_log中的错误(在的/ etc / httpd的/日志
)。
There are no errors written to the error_log (on /etc/httpd/logs
).
如果我ssh到机器,手动启动该服务,它开始没有问题。
If I ssh into the machine and start the service manually, it starts with no problem.
我曾与CentOS的其它盒同样的问题(上vagrantcloud.com如厨师/ CentOS的-6.5
可用),这就是为什么我创建了一个我自己。
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.
其他服务,比如MySQL,开始很好,所以它特定于Apache的一个问题。
Other services, like mysql, start fine, so it's a problem specific to apache.
- 的httpd总是在第一次启动开始,即使提供的脚本(如无业游民后销毁)
- 的httpd总是开始的时候我不跑的规定脚本(但我需要它来设置的DocumentRoot)
- 的httpd不先停止之后开始,具有与DocumentRoot的(不知道这就是问题所在)弄乱的规定脚本。
这是我的Vagrantfile:
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
).
这些都是我试图提供脚本(bootstrap.sh)。我希望他们做的唯一一件事就是DocumentRoot的更改为无业游民文件夹。但是都没有成功。
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.
1试试
#!/usr/bin/env bash
sudo rm -rf /var/www/html
sudo ln -fs /vagrant/app/webroot /var/www/html
2试试
#!/usr/bin/env bash
sudo cp /vagrant/vagrant_files/httpd.conf /etc/httpd/conf
sudo service httpd restart
这是第二次尝试在httpd.conf等于默认的,除了DocumentRoot路径。这第二个选择可以让我做无业游民了--provision
来强制服务的重新启动,但应该是一个不必要的步骤。
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.
推荐答案
显然,问题是由于当阿帕奇试图启动不被安装在颠沛流离的文件夹。虽然我还是不明白,为什么没有引发错误。
Apparently the problem was due to the vagrant folder not being mounted when Apache tries to start. Although I still don't understand why no error is thrown.
我解决它通过创建一个暴发户脚本(该文件夹的/ etc /初始化
)的流浪汉登上它的文件夹后启动服务(它发射称为事件流浪汉式
)
I solved it by creating an Upstart script (on the folder /etc/init
) to start the service after vagrant mounts its folder (it emits an event called vagrant-mounted
)
这是我使用的脚本(与文件名的httpd.conf
,但我不认为这是必要的)。
This is the script I used (with the filename httpd.conf
but I don't think that's necessary).
# start apache on vagrant mounted
start on vagrant-mounted
exec sudo service httpd start
暴发户可以做更多的事情,但这种解决它。
Upstart can do much more but this solves it.
这篇关于Apache的流浪重装后无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!