6

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.

Error:

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> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> 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 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> <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 </Proxy> ProxyPass / http://localhost:8022/ ProxyPassReverse / http://localhost:8022/ </VirtualHost> 

UPDATE

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.

5
  • 2
    Have you checked the lines proceeding the lines quoted in the error? Commented Jun 28, 2010 at 19:22
  • Since the error is on line 1 something is probably broken on a some other file and not 000-default Commented Jun 28, 2010 at 19:26
  • Check the proceeding lines as Chris says, and also try disabling one site at a time until Apache starts loading again. Commented Jun 28, 2010 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. Commented Jun 28, 2010 at 20:24
  • Please add the content of apache2.conf Commented Jun 28, 2010 at 22:32

6 Answers 6

1

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)

0

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

0

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.

Also

allow from 

should be

Allow from 

same goes for

require 

should be

Require 
0

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

Syntax error on line 41 of /etc/apache2/sites-enabled/000-default.save: </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.

0

I had the same problem today running apache 2.4.18. The problem was a missing newline at the end of the file. So make sure to put an additional newline after </VirtualHost>

-2

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.

1
  • 3
    Apache configuration files are not XML. They look similar in some ways, but they don't follow the same rules. Commented May 9, 2011 at 19:47

You must log in to answer this question.