2014-03-04 132 views
0

我想使用厨师创建一个本地虚拟主机,并为此我在我的运行列表中添加了“食谱[apache2]”食谱,它工作得很好,直到我还在食谱中添加了另一个食谱包含默认apache2配方的运行列表。现在,即使我从运行列表中删除新配方,“开始”操作失败,并出现以下错误。任何人都知道这是什么原因?apache2厨师食谱开始失败

================================================================================ 
Error executing action `start` on resource 'service[apache2]' 
================================================================================ 


Mixlib::ShellOut::ShellCommandFailed 
------------------------------------ 
Expected process to exit with [0], but received '1' 
---- Begin output of /etc/init.d/apache2 start ---- 
STDOUT: * Starting web server apache2 
Action 'start' failed. 
The Apache error log may have more information. 
    ...fail! 
STDERR: Syntax error on line 2 of /etc/apache2/sites-enabled/example.conf: 
ServerName takes one argument, The hostname and port of the server 
---- End output of /etc/init.d/apache2 start ---- 
Ran /etc/init.d/apache2 start returned 1 


Resource Declaration: 
--------------------- 
# In /var/chef/cache/cookbooks/apache2/recipes/default.rb 

210: service 'apache2' do 
211: action :start 
212: end 



Compiled Resource: 
------------------ 
# Declared in /var/chef/cache/cookbooks/apache2/recipes/default.rb:210:in `from_file' 

service("apache2") do 
    action [:start] 
    supports {:restart=>true, :reload=>true, :status=>true} 
    retries 0 
    retry_delay 2 
    service_name "apache2" 
    pattern "apache2" 
    restart_command "/usr/sbin/invoke-rc.d apache2 restart && sleep 1" 
    reload_command "/usr/sbin/invoke-rc.d apache2 reload && sleep 1" 
    cookbook_name "apache2" 
    recipe_name "default" 
end 



[2014-03-04T17:52:20+00:00] INFO: Running queued delayed notifications before   re-raising exception 
[2014-03-04T17:52:20+00:00] ERROR: Running exception handlers 
[2014-03-04T17:52:20+00:00] ERROR: Exception handlers complete 
[2014-03-04T17:52:20+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out 
[2014-03-04T17:52:20+00:00] INFO: Sending resource update report (run-id: 3d91fc5b-cf02-4788-bb56-f03ebe274702) 
[2014-03-04T17:52:21+00:00] ERROR: service[apache2] (apache2::default line 210) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1' 
---- Begin output of /etc/init.d/apache2 start ---- 
STDOUT: * Starting web server apache2 
Action 'start' failed. 
The Apache error log may have more information. 
    ...fail! 
STDERR: Syntax error on line 2 of /etc/apache2/sites-enabled/example.conf: 
ServerName takes one argument, The hostname and port of the server 
---- End output of /etc/init.d/apache2 start ---- 
Ran /etc/init.d/apache2 start returned 1 
[2014-03-04T17:52:21+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) 

回答

1

/etc/apache2/sites-enabled/example.conf看一看:输出表示

服务器名称需要一个参数,服务器的主机名和端口

很显然,你没有通过sever_name属性 - 看看README和使用的template

web_app "my_site" do 
    server_name node['hostname'] 
    server_aliases [node['fqdn'], "my-site.example.com"] 
    docroot "/srv/www/my_site" 
end 

如果这没有帮助,请编辑您的帖子并添加如何定义示例网站的代码。