所以,问题看起来很简单,但不幸的是,我尝试解决它却没有结果。Apache 仍然看不到“/web”目录(例如,我无法加载那里存在的 css 样式或图像)。下面是我的httpd-vhosts.conf:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www\projekt2\web"
ServerName projekt2.dev
ServerAlias projekt2.dev www.projekt2.dev
Options Indexes FollowSymLinks
<Directory "C:\wamp64\www\projekt2\web">
# AllowOverride All
# Order Allow,Deny
# Allow from All
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
</VirtualHost>
以及Windows目录中的hosts.conf:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 projekt2.dev
::1 projekt2.dev
有人知道如何解决这个问题吗?我将不胜感激。
答案1
我只是想确定一下 - 您看不到哪个虚拟主机?ServerName localhost 还是 ServerName localhost?
我看到您在 Windows 上运行 Apache,所以我不确定这些命令行开关是否有效,因为我在 Linux 上将它们用于 Apache。
/usr/local/apache2/bin/httpd -S
它将输出 Apache 如何解析配置文件的描述。仔细检查可能有助于发现配置错误。
httpd -t
仅对配置文件运行语法测试。
权限在这里也起着重要作用。apache 服务(守护进程)帐户是否有权访问无法访问的文件的位置?