原始的 httpd-vhosts.conf 配置文檔如下:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/data/webapps/test01"
ServerName www.test01.com
<Directory "/data/webapps/test01">
AllowOverride All
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/data/webapps/test02"
ServerName www.test02.com
<Directory "/data/webapps/test02">
AllowOverride All
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
然後報錯:
AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/extra/httpd-vhosts.conf:1
原因是apache-2.4.x版本後的NameVirtualHost *:80這句已經多餘,無需寫入配置文檔,刪除即可
AH00526: Syntax error on line 3 of /usr/local/apache/conf/extra/httpd-vhosts.conf:
Invalid command '\xc2\xa0', perhaps misspelled or defined by a module not included in the server configuration
\xc2\xa0:是一個叫做Non-breaking space的東西,用於阻止在此處自動換行和阻止多個空格被壓縮成一個
是由於空格導致的問題,把空格修改一下就可以了