hos maya apache
伊谢尔伦
伊谢尔伦 2017-05-16 16:57:58
0
3
753

Saya sedang menyelidik hos maya baru-baru ini, dan kemudian saya mengkonfigurasi dua hos maya seperti berikut

Salah satu daripadanya mempunyai ServerName ditetapkan kepada 127.0.0.1. Kemudian tambahkan

pada fail hos pada pemacu C

Kemudian soalan datang.
Apabila saya terus memasukkan www.abc.com dalam penyemak imbas, saya akan mengakses projek E:/wamp/crm Mengapa? Bukankah www.abc.com sepadan dengan 127.0.0.1 dalam hos Bukankah ia sepatutnya diakses oleh E:/wamp/wamp/www? Kemudian apabila saya terus memasukkan 127.0.0.1 dalam penyemak imbas, saya mengakses projek E:/wamp/wamp/www? Cuma saya tidak faham di sini. . . . Tolong bantu saya ya Allah. . . . . .

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

membalas semua (3)
洪涛

官方文档在此:An In-Depth Discussion of Virtual Host Matching

你这个属于“Name-based vhost”,就看这一段好了:

If there are multiple VirtualHost directives listing the IP address
and port combination that was determined to be the best match, the
"list" in the remaining steps refers to the list of vhosts that
matched, in the order they were in the configuration file.

我来简单翻译,在vhost IP和端口吻合的情况下(就是你这里的*:80),apache会根据vhost配置文件中vhost的先后顺序依次进行匹配.

If the connection is using SSL, the server supports Server Name
Indication, and the SSL client handshake includes the TLS extension
with the requested hostname, then that hostname is used below just
like the Host: header would be used on a non-SSL connection.
Otherwise, the first name-based vhost whose address matched is used
for SSL connections. This is significant because the vhost determines
which certificate the server will use for the connection.

如果是SSL连接,会根据TLS握手信息里面的SNI寻找主机名。如果不支持SNI,就匹配给第一个IP和端口(这里指的还是 *:80)吻合的vhost.

If the request contains a Host: header field, the list is searched for
the first vhost with a matching ServerName or ServerAlias, and the
request is served from that vhost. A Host: header field can contain a
port number, but Apache always ignores it and matches against the real
port to which the client sent the request.

如果HTTP头部有Host信息,则匹配给第一个和ServerName或者ServerAlias吻合的虚拟主机。有的时候Host会包含端口信息,Apache不会鸟这个端口。

The first vhost in the config file with the specified IP address has the highest priority and catches any request to an unknown server name, or a request without a Host: header field (such as a HTTP/1.0 request).

如果都没匹配上,扔给第一个IP端口(指的还是你的那个*:80)吻合的vhost

你访问的abc.com是第一个crm那个么?不是, 是127.0.0.1么(只有地址栏直接输入127.0.0.1才算)? 不是,那就走默认的,也就是第一个crm的配置。

    过去多啦不再A梦

    个人感觉serverName没啥用,所以你这个按优先适配原则,按80端口就直接是第一条规则。你要真想挂俩站点,用端口号区分就好了~
    另外也可以看看文档。中文文档推荐译者:金步国的。

      大家讲道理

      域名是用来解析为IP的,所以两个都是127.0.0.1
      而你的两个端口同样是80,只能访问第一个了

      你把下面的的改为8080,用8080端口访问第二个

        Muat turun terkini
        Lagi>
        kesan web
        Kod sumber laman web
        Bahan laman web
        Templat hujung hadapan
        Tentang kita Penafian Sitemap
        Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!