Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 无法识别虚拟主机_Apache_Virtualhost_Vhosts - Fatal编程技术网

Apache 无法识别虚拟主机

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

目前我正在尝试设置VHost,但不知怎的,它不起作用。 我已经禁用了我机器中的虚拟主机,我只有一个。该页面未加载。如果我访问localhost,我将得到403禁止

我的虚拟主机:

<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
eg
SetHandler 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