gpt4 book ai didi

apache - XAMPP 虚拟主机不工作

转载 作者:行者123 更新时间:2023-12-04 13:26:15 25 4
gpt4 key购买 nike

在将其标记为已回答之前,请阅读整篇文章,因为是的,这些问题有很多,但没有一个答案奏效。

在过去的 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 次试图使其工作。

最佳答案

如果您在使用 XAMPP 的 Windows 环境(7 和 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

  • 在 httpd.conf [ C:\__Server\apache\conf 中添加这个]。虽然有人说这有安全风险,但没有这个就找不到方法

  • <Directory />
    AllowOverride none
    Require all granted
    </Directory>

  • 在 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>


    这个模板
    <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 [i.e.com.at] 中使用不常见的部分,这样它是唯一的,并且解析 dns 没有问题。

    更新:疑难解答@Jacob Jewett

    在 C 驱动器中安装 XAMPP 的全新副本后 -
  • 只需在 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>

  • 在 httpd.conf 文件中添加附加内容

  • <Directory />
    AllowOverride none
    Require all granted
    </Directory>

  • 地址 PATH php 变量 [C:\xampp\php] & slao 检查 PATH 中没有其他 php 路径多变的。
  • 重新启动 xampp 并浏览本地主机
  • 关于apache - XAMPP 虚拟主机不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38538859/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com