XAMPP虚拟主机无法正常工作

Jac*_*ett 5 apache xampp virtual host google-chrome

在将此标记为已回答之前,请阅读整篇文章,因为是的,有很多这些问题但是没有任何答案可以使用.

在过去的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
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

我无法做什么,我已经尝试将所有字段放到localhost然后到instancegaming.net但似乎没有任何工作.我已经阅读了Apache日志,并且只有SSL错误.

当我尝试访问[http://] vws.localhost,vws.192.168.0.47,vws.instancegaming.net时,所有这些都会在chrome中产生相同的错误:

ERR_NAME_NOT_RESOLVED

然后我尝试清空chromes主机缓存,但这也没有帮助.旁注:我重新安装了XAMPP 4次试图完成这项工作.

Ati*_*qur 12

如果您在使用XAMPP的Windows环境(7和10测试)中,请执行以下步骤:

  1. 添加主机文件[ C:\Windows\System32\drivers\etc]
127.0.0.1       vws.localhost
127.0.0.1       instancegaming.net
127.0.0.1       vws.instancegaming.net
Run Code Online (Sandbox Code Playgroud)
  1. 在httpd.conf [ C:\__Server\apache\conf]中添加它.虽然有人说这有安全风险,但没有这个就找不到办法
<Directory />
    AllowOverride none
    Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
  1. 在httpd-vhosts.conf [ 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>
Run Code Online (Sandbox Code Playgroud)

这个模板

<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>
Run Code Online (Sandbox Code Playgroud)

注意-1:我的xampp安装在C:\__Server位置上

注意2:我的文件夹名称是laravel.test.com.atE:驱动器中的名称 E:\laravel.test.com.at

注意3:始终从Windows资源管理器中的地址栏复制文件夹位置,因此没有错误.

注4:每次编辑httpd-vhosts.conf后都必须重启XAMPP.

注意5:在url [ie .com.at]中使用不常见的部分,这样它就是唯一的,并且解决dns没有问题.

更新:排除@ Jacob Jewett故障

在C盘中安装XAMPP的新副本后 -

  1. 只需在httpd-vhosts.conf文件中添加/附加这些行
<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>
Run Code Online (Sandbox Code Playgroud)
  1. 添加将其添加到httpd.conf文件中
<Directory />
    AllowOverride none
    Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
  1. PATHphp [C:\ xampp\php]和slao的ADD 变量检查PATH变量中没有其他php路径.

  2. 重启xampp并浏览localhost