XAMPP虚拟主机不工作 [英] Xampp vhosts do not work

查看:239
本文介绍了XAMPP虚拟主机不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有XAMPP麻烦。已经安装了它,我的虚拟主机不希望在所有的工作。
当我试图访问的http://本地主机/ - 做工不错。但是,如果我输入别的东西,像 http://laravel.dev 它给了我一个错误。

I have trouble with xampp. Having installed it, my virtual hosts do not want to work at all. When i am trying to access http://localhost/ - works good. But if i type something else, like http://laravel.dev it gives me an error.

主机

# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost


127.0.0.1       localhost
127.0.0.1       laravel.dev

虚拟主机

# 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>

谢谢!

推荐答案

我有同样的问题,当我第一次开始使用XAMPP。这是真的很难在网上找到答案,所以我已经开始尝试自己。为我工作的解决方案是为清除浏览器缓存。 :)是,这是简单的,因为这...

I had the same problem when I first started to use XAMPP. It was really hard to find answer online, so I have started to experiment myself. The solution that worked for me was to clear the browser cache. :) Yes that was simple as this ...

对于那些谁不知道:

主机文件可以在 C下找到:\\ WINDOWS \\ SYSTEM32 \\ drivers \\ etc下目录和

hosts file can be found in C:\Windows\System32\drivers\etc directory and

的httpd-vhost.conf 中可以找到的 C:\\ XAMPP的\\ apache的\\的conf \\额外目录

httpd-vhost.conf can be found in C:\xampp\apache\conf\extra directory

诗。在这里你去 - 我的工作配置。 (不要忘了清除浏览器缓存,你所做的更改这些文件后并重新启动Apache服务器在XAMPP面板)的请注意,编辑hosts文件,你必须运行编辑程序,如记事本++作为管理员。如果你不这样做,你的编辑程序将无法作出该文件的任何修改。*

Ps. here you go - my working configuration. (Don't forget to clear your browser cache after you have made the changes to those files and restart your Apache server in your xampp panel) Note that to edit hosts file you have to run the editing program such as Notepad++ as administrator. If you don't do it your editing program will not be able make any changes to that file.*

主机

127.0.0.1  symfony.dev
127.0.0.1  symfony

的httpd-vhost.conf

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>

还有一小东西......当您运行在浏览器中的虚拟服务器确保您将使用http://之前的服务器名称(最后在第一时间,你会称呼它)。所以运行:

One more little thing... When you run your virtual server in the browser make sure that you will use http:// before the server name (at last at the first time you will call it). So run:

http://symfony.dev

之后,你就可以只用

symfony.dev

symfony.dev

(那它是如何工作的谷歌Chrome浏览器反正)

(That how it works in a Google Chrome browser anyway)

竖起大拇指,如果我已经帮助解决您的问题;-)。

Thumbs up if I have helped to solve your issue ;-).

亲切的问候

这篇关于XAMPP虚拟主机不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆