Problem with Document Root arugment

153 views
Skip to first unread message

Rick Westbrock

unread,
Jun 11, 2014, 12:17:09 PM6/11/14
to learnchef-funda...@googlegroups.com
For some reason my custom-vhosts.erb file is not getting compiled due to an error with the DocumentRoot line. chef-client is complaining about line 5 of my bears.conf file saying "DocumentRoot takes one argument, Root directory of the document tree"

When I open that file on my lab server there is no argument after DocumentRoot even though it should be 

A few lines down that variable was parsed correctly for the bears sub-directory and the file /srv/apache/bears/index.html is present and looks correct.

Any idea why I am having such a problem with the DocumentRoot argument? Below is the content of my custom-vhosts.erb file.

<% if @port != 80 %>
  Listen <%= @port %>
<% end %>

<VirtualHost *:<%= @port %>>
    ServerAdmin webmaster@localhost
  
  DocumentRoot <%= @document_Root %>
    <Directory />
      Options FollowSymlinks
      AllowOverride None
    </Directory>
  <Directory <%= @document_root %>>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow, deny
    allow from all
  </Directory>
</VirtualHost>

Michael Washington

unread,
Jun 12, 2014, 3:27:47 AM6/12/14
to learnchef-funda...@googlegroups.com
I am also getting an error when the httpd device tries to start. It states:
Syntax error on line 5 of /etc/httpd/conf.d/bears.conf: <Directory> directive requires additional parameters.

After looking at the file in the VM it shows the directive without the ending space and slash i.e. it should look like <Directory /> instead of just <Directory>.
I manually went into the file user VIM and fixed and httpd started right up.

Rick Westbrock

unread,
Jun 12, 2014, 8:18:21 AM6/12/14
to learnchef-funda...@googlegroups.com
Have you run chef-client on the node after making that manual change? I am sure that it would overwrite the file. It defeats the purpose of chef if you have to make manual changes.

Nathen Harvey

unread,
Jun 12, 2014, 10:08:34 PM6/12/14
to learnchef-funda...@googlegroups.com
Rick,

Might be easier if you posted your file over on gist.github.com.  Makes it a bit easier to help with errors.

You have a line that says:

DocumentRoot <%= @document_Root %>

it should read:

DocumentRoot <%= @document_root %>

Notice the lower case "r" in "@document_root".

Give that a try and see if it resolves your error. 

One hint though, you may need to move your service["httpd"] resource to the end of your vhosts.rb recipe.

-Nathen

Nathen Harvey

unread,
Jun 12, 2014, 10:10:41 PM6/12/14
to learnchef-funda...@googlegroups.com
Michael,

Double-check your custom-vhosts.erb.  Is it correct?

You'll find a good copy of that file here:

Rick Westbrock

unread,
Jun 13, 2014, 11:42:35 AM6/13/14
to learnchef-funda...@googlegroups.com
Thanks for the feedback Nathen. I corrected that pesky capital "R" but that didn't resolve the issue. I uploaded my custom-vhosts.erb files as below:

I then moved the service["httpd"] in my vhosts.erb file down to the bottom which didn't help either. This original vhosts.erb file worked fine in Module 3, I didn't have any problems until I added the files & changes in Module 4.


I am still getting the same error due to the /etc/httpd/conf.d/bears.conf file not having an argument for the DocumentRoot. Below is the file from my lab server and a snippet of the errors; I linked to the full error log as well.


---- Begin output of /sbin/service httpd start ----
STDOUT: Starting httpd: [FAILED]
STDERR: Syntax error on line 5 of /etc/httpd/conf.d/bears.conf:
DocumentRoot takes one argument, Root directory of the document tree
---- End output of /sbin/service httpd start ----

Contents of bears.conf:
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

  DocumentRoot
    <Directory />
      Options FollowSymlinks
      AllowOverride None
    </Directory>
  <Directory /srv/apache/bears>

Nathen Harvey

unread,
Jun 24, 2014, 12:53:36 PM6/24/14
to learnchef-funda...@googlegroups.com
Try moving your service[httpd] resource to the end of the vhosts.rb file and removing it from your default.rb recipe.  I think that may solve the problem.

Let me know if that does and I'm happy to help explain "why" it solved it.

-Nathen

Rick Westbrock

unread,
Jul 22, 2014, 1:49:12 PM7/22/14
to learnchef-funda...@googlegroups.com
Sorry for the late reply, I had some critical work that prevented me from keeping current on this course. Moving that resolved the errors however now Apache won't start automatically. I provisioned a new node in my webserver role and it installed Apache without error but I didn't see it start the service. I manually started the service but need to debug my code since it's not serving up web pages any longer.

I uploaded my new vhosts.rb and default.rb files for reference here: https://gist.github.com/rwestbrock/c73047850d8c253b8479 



Rick Westbrock

unread,
Jul 22, 2014, 2:05:14 PM7/22/14
to learnchef-funda...@googlegroups.com
Solved my issue, I had removed apache::vhosts from the cookbook temporarily to bypass the error. I added that recipe to my node's run list and now Apache does start and builds the files for bears and clowns. In fact it seems to go overboard now with a start then a restart:
  * service[httpd] action enable (up to date)
  * service[httpd] action start (up to date)
  * service[httpd] action restart
    - restart service service[httpd]

As before however I can't get a page to load in my browser so I will still have to go back to my code to debug.

Rah Dev

unread,
Sep 22, 2015, 12:30:52 PM9/22/15
to learnchef-fundamentals-webinar
Hi Nathan, your suggestion worked for me, please explain why...Thank you.
Reply all
Reply to author
Forward
0 new messages