nginx域名配置虛擬主機(jī)
一個(gè)域名,對應(yīng)一個(gè)IP地址

通過DNS域名解析服務(wù)器,可以將域名解析為IP地址
這里
通過修改host文件,指定域名的IP地址
host劫持
是指在host文件中,配置域名和IP地址,當(dāng)訪問域名的時(shí)候
因?yàn)椋琱ost文件中已經(jīng)有了域名所對應(yīng)的IP地址
所以,不再需要訪問DNS服務(wù)器進(jìn)行解析,直接訪問對應(yīng)的IP地址
host文件的位置
C:\Windows\System32\drivers\etc
Nginx配置文件注釋:
?[root@localhost conf]# vim nginx.confworker_processes? 1;? ? #worker進(jìn)程的數(shù)量events {? ? ? ? ? ? ? ? #事件塊的開始worker_connections? 1024;? ? ? ? ? ? #每個(gè)worker進(jìn)程支持的最大連接數(shù)}? ? ? ? ? ? ? ? ? ? ? ?#事件塊的結(jié)束http {? ? ? ? ? ? ? ? ? #HTTP區(qū)塊的開始include? ? ? ?mime.types;? ? ? ? ? ? ? ? #Nginx支持媒體類型庫文件default_type? application/octet-stream;? ? #默認(rèn)的媒體類型sendfile? ? ? ? on;? ? ? ? ? ? ? ? ? ? ? ? #開啟高速傳輸模式keepalive_timeout? 65;? ? ? ? ? ? ? ? ? ? ?#連接超時(shí)server {? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #第一個(gè)server區(qū)塊的開始? ? listen? ? ? ?80;? ? ? ? ? ? ? ? ? ? ? ? #提供服務(wù)的端口,默認(rèn)為80? ? server_name? ?www.nautilus.org ;? ? ? ? ? ? ? ? ?#提供服務(wù)的域名主機(jī)? ? location / {? ? ? ? ? ? ? ? ? ? ? ? ? ? #第一個(gè)location區(qū)塊的開始? ? ? ? root? ?html/www;? ? ? ? ? ? ? ? ? ? ? ? #站點(diǎn)的根目錄,相當(dāng)于Nginx的安裝目錄? ? ? ? index? index.html index.htm;? ? ? ? #默認(rèn)的首頁文件,多個(gè)使用空格隔開? ? }? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #第一個(gè)location區(qū)塊的結(jié)束? ? error_page? ?500 502 503 504? /50x.html;? ? #出現(xiàn)對應(yīng)的http狀態(tài)碼是,使用50x.html回應(yīng)客戶? ? location = /50x.html {? ? ? ? ? ? ? ? ? ? #location區(qū)塊的開始,訪問50x.html? ? ? ? root? ?html;? ? ? ? ? ? ? ? ? ? ? ? ? ? #指定對應(yīng)的站點(diǎn)目錄為html? ? }}}? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#HTTP區(qū)塊的結(jié)束操作步驟
[root@localhost nginx]# lsclient_body_temp? fastcgi_temp? logs? ? ? ? sbin? ? ? ?uwsgi_tempconf? ? ? ? ? ? ? html? ? ? ? ? proxy_temp? scgi_temp[root@localhost nginx]# cd html[root@localhost html]#[root@localhost html]# mkdir www? ? [root@localhost html]#? ? ? [root@localhost html]# cd www[root@localhost www]# lsindex.html[root@localhost www]# vim index.html? ?hello? localhost[root@localhost nginx]# vim /etc/hosts127.0.0.1? ?localhost localhost.localdomain localhost4 localhost4.localdomain4::1? ? ? ? ?localhost localhost.localdomain localhost6 localhost6.localdomain6172.31.1.32
了解更多相關(guān)內(nèi)容歡迎關(guān)注http://www.vecloud.com/