Question

I am using Chef to build out a virtual machine on Rackspace. The VM is a RHEL 6.5 box.

I am running into problems building the default Apache2 /etc/httpd/conf/httpd.conf file cleanly for RHEL using the Apache2 recipe (it appears to default to an Ubuntu flavor configuration).

In the recipe config template (apache2/templates/default/apache2.conf.erb) there is no place to define ServerName. Consequently when I test Apache is working properly I get the following

% apachectl configtest
httpd: Could not reliably determine the server's fully qualified domain name, using ##### for ServerName
Syntax OK

where ##### is my DNS, listed in my /etc/hosts and defined in my cookbook recipe attributes/default.rb file as servername.

If I look in the recipe template I don't see any location for the variable ServerName (first 17 lines):

#
# Generated by Chef
#
# Based on the Ubuntu apache2.conf

ServerRoot "<%= node['apache']['dir'] %>"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
<% if %w[debian].include?(node['platform_family']) -%>
LockFile /var/lock/apache2/accept.lock
<% elsif %w[freebsd].include?(node['platform_family']) -%>
LockFile /var/log/accept.lock
<% else %>
LockFile logs/accept.lock
<% end -%>

Now, if I manually go and edit /etc/httpd/conf/httpd.conf, adding a ServerName variable, everything works. Relevant before and after below:

BEFORE

#
# Generated by Chef
#
# Based on the Ubuntu apache2.conf

ServerRoot "/etc/httpd"

AFTER

#
# Generated by Chef
#
# Based on the Ubuntu apache2.conf

ServerRoot "/etc/httpd"
ServerName #####:80

Now when I test Apache:

% apachectl configtest
Syntax OK

Obviously the whole point of using Chef is to not hand edit configuration files, and whenever I rerun my chef recipe with chef-solo I am going to blow this customization away. I am so new to Chef that I don't really want to fork the cookbook on Github and make a new template for RHEL, but maybe that's what I need to do?

I am hoping there is just one configuration setting in my overall recipe I am not defining, that will add this variable to my core Apache httpd.conf file.

Hopefully someone with more experience with Chef, and in particular the Apache2 cookbook, can help me. Thanks in advance.

EDIT #1

A look at netstat -tulpn shows that I think Apache (httpd) is actually working, or at least listening in on port 80:

% netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1274/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1677/master         
tcp        0      0 **.***.*.***:3306           0.0.0.0:*                   LISTEN      1585/mysqld         
tcp        0      0 :::80                       :::*                        LISTEN      6663/httpd          
tcp        0      0 :::22                       :::*                        LISTEN      1274/sshd           
tcp        0      0 ::1:25                      :::*                        LISTEN      1677/master

Is it looking more and more like a networking (DNS) issue?

EDIT #2

Based on the helpful comments to my original post I think I originally misdiagnosed this. I just built a new Ubuntu VM and installed Apache2 by hand using sudo apt-get install apache2 (ie. not using chef-solo) and I see the same installed layout of apache2 that my Chef recipe created on my RHEL VM. I also get the same warning when running apachectl configtest:

apache2: Could not reliably determine the server's fully qualified domain name, using ##### for ServerName
Syntax OK

When I point the browser on Ubuntu to 127.0.0.1:80 I see the 'It works!' standard Apache response. So, my issue is not really an issue. My thinking now is that this is a network problem. iptables?

EDIT #3

I just ssh'd into my RHEL VM and installed Firefox. I then opened it up and pointed it to 127.0.0.1:80 and I get the default page. I think this categorically confirms that I have a DNS issue. Time to speak to my networking admin.

Was it helpful?

Solution

As per the helpful comments from users cassianoleal and StephenKing, this "error" was actually a red herring. It is just an Apache warning that has no effect on if httpd is actually running or not.

The problem was really that I wasn't updating my iptables config. Once I installed the Chef cookbook simple_iptables and added a simple_iptables_rule to my Chef recipe to update my iptables to listen on ports 80 and 443, everything worked.

Live and learn I guess.

For the record, Chef is highly recommended if you aren't using it yet!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top