[英]XAMPP Virtual Hosts not working
Before marking this as answered, please read the entire thing because yes there is a good amount of these questions but NONE of the answers on them have worked at all.在将其标记为已回答之前,请阅读整篇文章,因为是的,这些问题有很多,但这些问题的答案都没有奏效。
For the last 6 months I've looked at around 50 different form posts here and around the web to try and get my XAMPP virtual hosts working.在过去的 6 个月里,我在这里和 web 周围查看了大约 50 个不同的表单帖子,试图让我的 XAMPP 虚拟主机正常工作。
Hosts File主机文件
127.0.0.1 localhost
127.0.0.1 vws.localhost
127.0.0.1 instancegaming.net
127.0.0.1 vws.instancegaming.net
http-vhosts File (Updated 7/26) http-vhosts 文件(7/26 更新)
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
# NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\xampp\htdocs"
<Directory "C:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
I'm at a loss of what to do, I've tried putting all fields to localhost then to instancegaming.net but nothing seems to work.我不知道该怎么做,我尝试将所有字段放到 localhost 然后放到 instancegaming.net 但似乎没有任何效果。 I've read the Apache log and there's only SSL errors floating around.
我已经阅读了 Apache 日志并且只有 SSL 错误浮动。
When I try going to [ http:// ] vws.localhost, vws.192.168.0.47, vws.instancegaming.net all of which give the same error in chrome:当我尝试访问 [ http:// ] vws.localhost, vws.192.168.0.47, vws.instancegaming.net 时,所有这些都在 chrome 中给出相同的错误:
ERR_NAME_NOT_RESOLVED
ERR_NAME_NOT_RESOLVED
Then I tried emptying chromes host cache, but that didn't help either.然后我尝试清空 chromes 主机缓存,但这也无济于事。 Sidenote: I reinstalled XAMPP 4 times trying to make this work.
旁注:我重新安装了 XAMPP 4 次试图使这项工作。
Follow these steps if you are in windows environment (7 & 10 tested) with XAMPP:如果您在使用 XAMPP 的 Windows 环境(7 和 10 测试)中执行以下步骤:
C:\\Windows\\System32\\drivers\\etc
]C:\\Windows\\System32\\drivers\\etc
]127.0.0.1 vws.localhost 127.0.0.1 instancegaming.net 127.0.0.1 vws.instancegaming.net
C:\\__Server\\apache\\conf
] .C:\\__Server\\apache\\conf
] 中添加它。 though some says there are security risks with this but couldn't find a way without this<Directory /> AllowOverride none Require all granted </Directory>
C:\\__Server\\apache\\conf\\extra
]C:\\__Server\\apache\\conf\\extra
] 中添加这些<VirtualHost *:80> ServerName localhost DocumentRoot "C:\\__Server\\htdocs" <Directory "C:\\__Server\\htdocs"> DirectoryIndex index.php </Directory> </VirtualHost> <VirtualHost *:80> ServerName tools.com.at DocumentRoot "E:\\phpStorms\\git\\tools-class" SetEnv APPLICATION_ENV "development" <Directory "E:\\phpStorms\\git\\tools-class"> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName laravel.test.com.at DocumentRoot "E:\\laravel.test.com.at\\public" SetEnv APPLICATION_ENV "development" <Directory "E:\\laravel.test.com.at\\public"> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
template of this这个模板
<VirtualHost *:80>
ServerName nameInHostsFile
DocumentRoot "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot"
SetEnv APPLICATION_ENV "development"
<Directory "pathOfTheWindowsFileLocationWhichWillBeDocumentRoot">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Note -1: My xampp installed on C:\\__Server
location注 -1:我的 xampp 安装在
C:\\__Server
位置
Note-2 : My folder name is laravel.test.com.at
and its in E:
drive E:\\laravel.test.com.at
注 2:我的文件夹名称是
laravel.test.com.at
并且它在E:
drive E:\\laravel.test.com.at
Note-3: Always copy folder location from address bar in windows explorer, so there is no mistakes.注意 3:始终从 Windows 资源管理器中的地址栏中复制文件夹位置,因此不会出错。
Note-4 : You must restart XAMPP after editing httpd-vhosts.conf every time .注4 :每次编辑httpd-vhosts.conf 后必须重启XAMPP 。
Note-5: Use uncommon part in url [ie .com.at] so that it is unique and there is no issue resolving dns.注 5:在 url [ie .com.at] 中使用不常见的部分,以便它是唯一的并且解析 dns 没有问题。
Update: troubleshoot@Jacob Jewett更新:疑难解答@Jacob Jewett
After a fresh copy of XAMPP installation in C drive -在 C 驱动器中安装 XAMPP 的全新副本后 -
<VirtualHost *:80> ServerName localhost DocumentRoot "C:\\xampp\\htdocs" <Directory "C:\\xampp\\htdocs"> DirectoryIndex index.php </Directory> </VirtualHost> <VirtualHost *:80> ServerName vws.localhost DocumentRoot "C:\\xampp\\vws" SetEnv APPLICATION_ENV "development" <Directory "C:\\xampp\\vws"> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
<Directory /> AllowOverride none Require all granted </Directory>
ADD PATH
variable for php [C:\\xampp\\php] & slao check there is no other php path in PATH
variable.为 php [C:\\xampp\\php] 添加
PATH
变量 & slao 检查PATH
变量中没有其他 php 路径。
restart xampp and browse localhost重新启动 xampp 并浏览本地主机
Additionally make sure that the line另外请确保该行
Include etc/extra/httpd-vhosts.conf
is not quoted out in httpd.conf
未在
httpd.conf
引用
One thing I'd like to add here: For anyone who is sure everything is setup correctly, make sure you don't use any underscores in the alias string within your hosts file;我想在这里补充一件事:对于任何确定一切都设置正确的人,请确保不要在 hosts 文件中的别名字符串中使用任何下划线; for some reason it can't accept underscores.
出于某种原因,它不能接受下划线。
我发现有效的答案是在主机文件中解决这个问题。
192.168.0.47 localhost somthing.instancegaming.net
I have similar issue, vhosts not working.我有类似的问题,虚拟主机不工作。 But in my case I found there was the permission issue with host file.
但就我而言,我发现主机文件存在权限问题。 Hope this helps for some one.
希望这对某些人有所帮助。 hosts file ignored, how to troubleshoot?
主机文件被忽略,如何排除故障?
If pings are successful but a Virtual Host is not working with XAMPP 7.3.1 and Windows 10 Pro the problem may be interference with the World Wide Web Publishing Service.如果 ping 成功,但虚拟主机不能与 XAMPP 7.3.1 和 Windows 10 Pro 一起使用,则问题可能是万维网发布服务的干扰。
On my system, Apache and MySQL start successfully but the virtual host cannot be browsed till I stop the WWWPS service (in Windows Services).在我的系统上,Apache 和 MySQL 成功启动,但在我停止 WWWPS 服务(在 Windows 服务中)之前无法浏览虚拟主机。 The virtual host then becomes instantly available.
然后虚拟主机立即可用。 It instantly stops working when the WWWPS is started again.
当 WWWPS 再次启动时,它会立即停止工作。
I fixed the problem by just restarting my computer after setting up the System32 file hosts and the apache vhosts.我通过在设置 System32 文件主机和 apache 虚拟主机后重新启动计算机解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.