0

我正在尝试使用 Chef 创建一个本地虚拟主机,为此我在我的运行列表中添加了“recipe [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)
4

1 回答 1

1

看看/etc/apache2/sites-enabled/example.conf:输出说

ServerName 有一个参数,服务器的主机名和端口

显然,您没有传递sever_name属性 - 请查看README和使用的模板

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

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

于 2014-03-04T19:46:39.310 回答