在将此标记为已回答之前,请先阅读整篇文章,因为是的,这些问题很多,但其中没有任何答案可以解决。
在过去的6个月里,我在这里和网络上查看了大约50个不同的表单帖子,试图让我的XAMPP虚拟主机工作。
主机文件
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文件(已更新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>
我不知道该做什么,我已经尝试将所有字段都放到localhost然后再到instancegaming.net但似乎什么都没有用。我已经阅读了Apache日志,并且只有SSL错误。
当我尝试访问[http://] vws.localhost,vws.192.168.0.47,vws.instancegaming.net时,所有这些都会在chrome中出现相同的错误:
ERR_NAME_NOT_RESOLVED
然后我尝试清空chromes主机缓存,但这也没有帮助。 旁注:我重新安装了XAMPP 4次试图完成这项工作。
答案 0 :(得分:10)
如果您在使用XAMPP的Windows环境(7&amp; 10测试)中执行以下步骤:
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
]中添加。 虽然有些人说这有安全隐患,但是如果没有这个就无法找到方法 <Directory /> AllowOverride none Require all granted </Directory>
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>
此
的模板<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>
注意-1:我的xampp已安装在C:\__Server
位置
注意2:我的文件夹名称为laravel.test.com.at
,其位于E:
驱动器E:\laravel.test.com.at
注意3:始终从Windows资源管理器中的地址栏复制文件夹位置,这样就没有错误。
Note-4 :每次编辑httpd-vhosts.conf后都必须重新启动XAMPP 。
注意5:在url [即.com.at]中使用不常见的部分,使其唯一且解决dns没有问题。
更新:排查@ Jacob Jewett
在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>
为php [C:\ xampp \ php]&amp;添加PATH
变量slao检查PATH
变量中没有其他php路径。
重新启动xampp并浏览localhost
答案 1 :(得分:0)
我发现答案的工作原理是在hosts文件中。
192.168.0.47 localhost somthing.instancegaming.net
答案 2 :(得分:0)
我想在此处添加一件事:对于确保一切设置正确的人,请确保您不在主机文件中的别名字符串中使用任何下划线;由于某种原因,它不能接受下划线。
答案 3 :(得分:0)
我有类似的问题,虚拟主机无法正常工作。但就我而言,我发现主机文件存在权限问题。希望这对某些人有所帮助。 hosts file ignored, how to troubleshoot?
答案 4 :(得分:0)
如果ping操作成功,但虚拟主机不能与XAMPP 7.3.1和Windows 10 Pro一起使用,则问题可能是与万维网发布服务有关。
在我的系统上,Apache和MySQL成功启动,但是直到停止WWWPS服务(在Windows Services中),才能浏览虚拟主机。然后,虚拟主机将立即可用。再次启动WWWPS时,它将立即停止工作。
答案 5 :(得分:0)
另外请确保该行
Include etc/extra/httpd-vhosts.conf
在httpd.conf
中未引用