Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I've already checked through my config file and I really can't see an instance where any tag hasn't been properly closed...but I keep getting this configuration error...Would you mind taking a look through the error and the config file below? Any assistance would be greatly appreciated.

FYI, I've already googled the life out of the error and looked through the log extensively, I really can't find anything.


apache2: Syntax error on line 236 of /etc/apache2/apache2.conf: syntax error on line 1 of /etc/apache2/sites-enabled/000-default: /etc/apache2/sites-enabled/000-default:1: was not closed.

Line 236 of apache2.conf:

# Include the virtual host configurations:                                      
Include /etc/apache2/sites-enabled/   

Contents of 000-default:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128


<VirtualHost *:443>
        SetEnvIf Request_URI "^/u" dontlog
        ErrorLog /var/log/apache2/error.log
        Loglevel warn
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/apache.pem

        ProxyRequests Off
        <Proxy *>
                AuthUserFile /srv/ajaxterm/.htpasswd
                AuthName EnterPassword
                AuthType Basic
                require valid-user

                Order Deny,allow
                Allow from all
        ProxyPass / http://localhost:8022/
        ProxyPassReverse / http://localhost:8022/


I had a load of other issues with my install so I wound up just wiping it and reinstalling. If I run into the same problem, I'll repost.

Everyone, thanks for your help/suggestions.

share|improve this question
Have you checked the lines proceeding the lines quoted in the error? – Chris S Jun 28 '10 at 19:22
Since the error is on line 1 something is probably broken on a some other file and not 000-default – Zoredache Jun 28 '10 at 19:26
Check the proceeding lines as Chris says, and also try disabling one site at a time until Apache starts loading again. – kaerast Jun 28 '10 at 19:30
To answer Chris S, yes, I've checked the preceeding lines, I've checked both files multiple times and can't find anything. Someone I know recommended that I try to remove the virtual host for port 80 and try again...Can you have more than one host in the file successfully? I'm going to try removing 80 when I get home tonight to see what happens. – Chris Jun 28 '10 at 20:24
Please add the content of apache2.conf – radius Jun 28 '10 at 22:32

I had the same problem in my virtualHosts config and solved it by converting Windows format file to Unix format file.

All characters "\r" (CR carriage return) need to be converted in "\n" unix (LF line feed)

share|improve this answer

you can try an grep "<Virtualhost>" -r /etc/apache2 to check all Open Virtual Hosts Tags

share|improve this answer

On Windows either the Apache bin directory needs to be in $PATH or you need to navigate to it. Then you can run:

httpd -t

Normally you will see:

Syntax Ok

If you want to check your virtual hosts specifically:

httpd -S

And it will start mentioning each host for each port.

Do you get the same error with httpd -t?

Can you remove your 000-default file and run the the command again? If you still get an error you are looking into the wrong file.

By the way your title is a little suggestive, I don't see any mention of "VirtualHost" in the error, the title suggests we should be looking for "" without a matching "" which is not the case.


allow from

should be

Allow from

same goes for


should be

share|improve this answer

For posterity's sake, I had a very similar error:

Syntax error on line 41 of /etc/apache2/sites-enabled/ </VirtualHost> without matching <VirtualHost> section

Opening that file I found a q before the opening <VirtualHost> tag. I have no idea how it got there, but removing it fixed the issue and allowed Apache to start.

share|improve this answer

I hate to answer so far in the future but on line 5 your tag is malformed namely <Directory /> should be <Directory "/">

I have also had issues with line ending characters between unix and windows and my apache config files.

share|improve this answer
Apache configuration files are not XML. They look similar in some ways, but they don't follow the same rules. – Jeff Snider May 9 '11 at 19:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.