Apache 无法识别虚拟主机
目前我正在尝试设置VHost,但不知怎的,它不起作用。 我已经禁用了我机器中的虚拟主机,我只有一个。该页面未加载。如果我访问localhost,我将得到403禁止 我的虚拟主机:Apache 无法识别虚拟主机,apache,virtualhost,vhosts,Apache,Virtualhost,Vhosts,目前我正在尝试设置VHost,但不知怎的,它不起作用。 我已经禁用了我机器中的虚拟主机,我只有一个。该页面未加载。如果我访问localhost,我将得到403禁止 我的虚拟主机: <VirtualHost *:80> ServerAdmin admin@myvhost.test ServerName myvhost.test DocumentRoot /folder/to/app <Directory /> Opt
<VirtualHost *:80>
ServerAdmin admin@myvhost.test
ServerName myvhost.test
DocumentRoot /folder/to/app
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /folder/to/app>
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我明白了
我错过了什么
谢谢在apache2/ports.conf中的配置中是否有
NameVirtualHost*:80
,这意味着VirtualHost
with*:80
是基于名称的虚拟主机。在这种情况下,Host
头必须与ServerName
/ServerAlias
匹配。定义ServerAlias localhost
多个选项
所有选项都必须带+/-(添加或删除标记)。对于CGI,必须定义适当的SetHandler
egSetHandler CGI脚本
。
apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server myvhost.test (/etc/apache2/sites-enabled/myvhost:1)
port 80 namevhost myvhost.test (/etc/apache2/sites-enabled/myvhost:1)
Syntax OK