Apache2configuration错误:“<VirtualHost>未closures”错误

所以我已经检查了我的configuration文件,我真的不能看到任何标签没有正确closures的实例…但我一直得到这个configuration错误…你介意看看通过错误和下面的configuration文件? 任何援助将不胜感激。

仅供参考,我已经从错误中search了生活,并且广泛地查看了日志,我实在找不到任何东西。

错误:

apache2:/etc/apache2/apache2.conf第236行的语法错误:/ etc / apache2 / sites-enabled / 000-default第1行的语法错误:/ etc / apache2 / sites-enabled / 000-default:1 :没有closures。

apache2.conf的第236行:

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

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

我的安装过程中遇到了一些其他问题,所以我只好清理并重新安装。 如果我遇到同样的问题,我会重新发布。

大家好,感谢您的帮助/build议。

我有我的virtualHostsconfiguration相同的问题,并通过将Windows格式文件转换为Unix格式文件解决它。

所有字符“\ r”(CR回车)需要在“\ n”unix(LF换行)

您可以尝试使用grep "<Virtualhost>" -r /etc/apache2来检查所有打开的虚拟主机标记

在Windows上,Apache bin目录需要在$ PATH中,否则你需要导航到它。 然后你可以运行:

 httpd -t 

通常你会看到:

 Syntax Ok 

如果你想特别检查你的虚拟主机:

 httpd -S 

它会开始提及每个端口的每个主机。

你有与httpd -t相同的错误吗?

你能删除你的000-默认文件并再次运行该命令? 如果您仍然收到错误,您正在查看错误的文件。

顺便说一下,你的标题有点暗示,我没有在错误中看到任何“VirtualHost”的提及,标题暗示我们应该在没有匹配的情况下寻找“”,而事实并非如此。

 allow from 

应该

 Allow from 

同样如此

 require 

应该

 Require 

为了后代的缘故,我有一个非常类似的错误:

 Syntax error on line 41 of /etc/apache2/sites-enabled/000-default.save: </VirtualHost> without matching <VirtualHost> section 

打开该文件,我在打开<VirtualHost>标记之前find了一个q 。 我不知道它是如何到达那里,但删除它解决了这个问题,并允许Apache启动。

我今天运行apache 2.4.18也有同样的问题。 问题是文件末尾缺less一个换行符。 所以确保在</VirtualHost>之后放置一个额外的换行符

我讨厌今后回答,但在第5行,你的标签格式不正确,即<Directory />应该是<Directory "/">

我也有行结束字符之间的UNIX和Windows和我的Apacheconfiguration文件的问题。