Apache Xampp虚拟主机不工作

Apache Xampp虚拟主机不工作,apache,xampp,virtualhost,virtual-hosts,Apache,Xampp,Virtualhost,Virtual Hosts,我在xampp方面有问题。安装后,我的虚拟主机根本不想工作。 当我试图访问http://localhost/ -效果很好。但是如果我键入其他内容,比如http://laravel.dev 这给了我一个错误 主人 虚拟主机 谢谢 您到底看到了什么样的错误 如果您没有在Vhost上指定正确的路径,则可能会出现问题。尝试将您的第二个vHost调整为以下内容: <VirtualHost *:80> ServerName laravel.dev DocumentRoot "C:

我在xampp方面有问题。安装后,我的虚拟主机根本不想工作。 当我试图访问http://localhost/ -效果很好。但是如果我键入其他内容,比如http://laravel.dev 这给了我一个错误

主人

虚拟主机


谢谢

您到底看到了什么样的错误

如果您没有在Vhost上指定正确的路径,则可能会出现问题。尝试将您的第二个vHost调整为以下内容:

<VirtualHost *:80>
    ServerName laravel.dev
    DocumentRoot "C:/xampp2/sites/laravel.dev/www"
    SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp2/sites/laravel.dev/www">
        DirectoryIndex index.php   ## Edit this to your needs, e.g. index.html
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

此外,我在使用绝对路径时遇到了一些问题,尝试使用相对路径,例如sites/laravel.dev/www,并检查这是否有区别。

我在第一次使用XAMPP时也遇到了同样的问题。在网上很难找到答案,所以我开始自己做实验。对我有效的解决方案是清除浏览器缓存:是的,就这么简单

对于那些不知道的人:

可以在C:\Windows\System32\drivers\etc目录和

httpd-vhost.conf可以在C:\xampp\apache\conf\extra目录中找到

注:给你-我的工作配置。在对这些文件进行更改后,不要忘记清除浏览器缓存,并在xampp面板中重新启动Apache服务器注意,要编辑主机文件,必须以管理员身份运行编辑程序,如Notepad++。如果您不这样做,您的编辑程序将无法对该文件进行任何更改。*

主人

httpd-vhost.conf

还有一件小事。。。在浏览器中运行虚拟服务器时,请确保在第一次调用服务器名称时,在服务器名称之前使用http://。因此,请运行:

之后,您将只能使用

symfony.dev

这就是它在Google Chrome浏览器中的工作原理

如果我帮你解决了问题,请竖起大拇指;-

问候

# 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>
    ##ServerAdmin webmaster@dummy-host.example.com
    ##DocumentRoot "C:/xampp2/htdocs/dummy-host.example.com"
    ##ServerName dummy-host.example.com
    ##ServerAlias www.dummy-host.example.com
    ##ErrorLog "logs/dummy-host.example.com-error.log"
    ##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
    ##ServerAdmin webmaster@dummy-host2.example.com
    ##DocumentRoot "C:/xampp2/htdocs/dummy-host2.example.com"
       ##ServerName dummy-host2.example.com
    ##ErrorLog "logs/dummy-host2.example.com-error.log"
    ##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "C:/xampp2/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp2/sites/laravel.dev/www"
    ServerName laravel.dev
</VirtualHost>
<VirtualHost *:80>
    ServerName laravel.dev
    DocumentRoot "C:/xampp2/sites/laravel.dev/www"
    SetEnv APPLICATION_ENV "development"
    <Directory "C:/xampp2/sites/laravel.dev/www">
        DirectoryIndex index.php   ## Edit this to your needs, e.g. index.html
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
127.0.0.1  symfony.dev
127.0.0.1  symfony
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@symfony.com
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ServerAlias 127.0.0.1
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@symfony.com
    DocumentRoot "C:/xampp/htdocs/www/_DoNotTouch_Symfony2/path/web"
    ServerName symfony.dev
</VirtualHost>