前幾日系統(tǒng)重裝導(dǎo)致hosts丟失,然后安裝了小皮面板后,創(chuàng)建網(wǎng)站會提示:hosts文件可能不存在或被阻止打開,同步hosts失敗,今天我們來提供下這個提示的解決方案。
解決辦法:
小皮面板安裝后,配置本地虛擬域名發(fā)現(xiàn),本地域名不能識別,發(fā)現(xiàn)時hosts文件沒有生效,解決方案如下:
hosts文件路徑:C:\Windows\System32\drivers\etc
第一種情況,hosts文件后綴名錯了,先排查hosts文件是否有擴(kuò)展名,因為hosts文件本身是沒有文件擴(kuò)展名的,如果不小心被加上了如txt等的文件擴(kuò)展名,就會失效。當(dāng)然,這么多年還沒犯這種錯誤。
第二種情況,hosts文件格式不正確,hosts文件中是有一定格式的:即單行一個dns的ip地址映射,可以一個ip對應(yīng)多個域名,每行的ip和域名之間至少有一個空格或TAB鍵。通常我們直接輸入都是正確的,而當(dāng)我們復(fù)制粘貼進(jìn)來的文本時,有時會因為換行符的問題不生效。解決方案,通過記事本或者notepad++修改即可。
# 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 |
第三種情況,如果感覺以上辦法太麻煩,很簡單,從其他電腦復(fù)制一份hosts文件放進(jìn)去即可。
END,以上方法輕松解決小皮面板的提示問題。