Apache complaining about html content
I have a few virtual hosts set up, and most are working fine. One, however, is a very old site which is deliberately there for legacy reasons.
When I reload apache with this site enabled, I get an error message from apache about the content of the html files.
It's clearly parsing them, and seems to be complaining (I assume that it thinks that they aren't well formed in some way).
I don't really want to change the html - it's old and crap but that's ok, it is a historical archive in effect.
What I want to do is just disable this checking for the site only, but I can't figure out what is doing it and how to turn it off.
Anyone got any ideas?
My setup is ubuntu 10.4/apache2/php5. Some of my other sites are Drupal based, but the one with the problem is pure html.
9 Replies
@akerl:
Link? Error message?
Sorry - I can give you the error message, but it's pointless - it's a specific error about some specific html in a specific file.
What I want to know is whether someone has come across this behaviour before (apache parsing the actual content of html files), and knows how to turn it off.
fwiw, here's an example of the error:
apache2: Syntax error on line 236 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/sites-enabled/05-old.elegantchaos.com/documents/lastexit/externals/Alias.html: /etc/apache2/sites-enabled/05-old.elegantchaos.com/documents/lastexit/externals/Alias.html:1: was not closed.
…fail!
@samdeane:
apache2: Syntax error on line 236 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/sites-enabled/05-old.elegantchaos.com/documents/lastexit/externals/Alias.html: /etc/apache2/sites-enabled/05-old.elegantchaos.com/documents/lastexit/externals/Alias.html:1: was not closed.
…fail!
It would appear that you've placed the document root of the transferred sites inside the /etc/apache2/sites-available folder (the "sites-enabled" folder only contains symlinks to those sites in "site-available" that have been activated). Considering that apache2.conf attempts to load /etc/apache2/sites-enabled/*, that would also mean any subfolders will be considered part of your Apache configuration.
Move the documents folders of each of your sites to somewhere else, and you would come a long way; ie. rather making them subfolders of locations like /home/www-data, /var/www, /srv or my own favorite flavor, /space/web (as long as the right directories are created and have the right permissions set, you can really place them almost anywhere you like).
So it sounds like Apache is trying to parse your HTML as a configuration file. Apache configuration files are XML, so you're probably getting an error from the XML parsing.
Files in sites-enabled are usually just links to files in sites-available, and are included from the main apache2.conf file.
– David
@db3l:
Are you sure you have the HTML files in the right location? /etc/apache/apache2/sites-available is a configuration directory for Apache and shouldn't be where you keep content.
So it sounds like Apache is trying to parse your HTML as a configuration file. Apache configuration files are XML, so you're probably getting an error from the XML parsing.
Files in sites-enabled are usually just links to files in sites-available, and are included from the main apache2.conf file.
– David
The way I have it set up, sites-available contains symbolic links for a number of other config files, one for each of my virtual hosts. Sites-enabled contains symbolic links which point to these.
I want it set up this way if possible, so that the config file for the site is located with the other files - each site is checked into its own git repository, so I really don't want the configs to have to live in a central location.
Good call about Apache trying to parse the html files as if they were config files though - that sounds a lot more plausible than it mysteriously deciding to validate my html!
I'll take another look in light of that idea…
It turns out that in sites-available I'd accidentally linked to the directory of the old site, instead of to the config file inside the directory.
So when I added old.elegantchaos.com to sites-enabled, I was actually adding a link to a link to a directory, instead of a link to a link to a config file. Apache obviously recurses into directories in sites-enabled…
All fixed now.
Thanks again for your help.
@samdeane:
All fixed now.
So that error message wasn't quite "pointless" :-)
– David
@db3l:
@samdeane:All fixed now.
So that error message wasn't quite "pointless":-) – David
I'll get my coat…