如何通过chef / vagrant在httpd.conf中添加“ServerName xxx”

时间:2013-05-17 14:48:27

标签: apache centos chef vagrant

我正在玩一个流浪汉的Centos 6.4盒子,

这是我的Vagrantfile的相关部分

  config.vm.provision :chef_solo do |chef|
    chef.json = {
        "apache" => {
            "listen_address" => "0.0.0.0",
            "server_name" => "localhost", # ?? this doesn't work
        },
    }
    chef.add_recipe "yum"
    chef.add_recipe "selinux::disabled"
    chef.add_recipe "vim"
    # chef.add_recipe "openssl"
    chef.add_recipe "apache2"
    chef.add_recipe "php"
    chef.add_recipe "php::module_curl"
    chef.add_recipe "php::module_mysql"
    chef.add_recipe "apache2::mod_php5"
    chef.add_recipe "apache2::mod_rewrite"
    chef.add_recipe "my"
  end

不幸的是,当我vagrant provision时,由于apache无法正常启动,我会收到一些错误。错误为httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

如果我做vagrant ssh那么我可以修复它将ServerName localhost添加到httpd.conf(/var/httpd/conf/httpd.conf)并且httpd服务正常启动。

如何在chef.json中添加此属性?

1 个答案:

答案 0 :(得分:1)

当您的服务器不知道自己的完全限定域名时,通常会导致此错误...尝试使用vagrant命令hostname进行设置:

config.vm.hostname = "server.name"

有关详情,请参阅此页:http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html