第七章 Nginx配置虛擬主機

2022-06-23 09:21:10 字數 1651 閱讀 1338

#虛擬主機配置方式:

1.基於多ip的方式

2.基於多埠的方式

3.基於多網域名稱的方式

1.第乙個配置檔案

[root@web02 /etc/nginx/conf.d]# vim mali.conf

server

}2.第二個配置檔案

[root@web02 /etc/nginx/conf.d]# vim tank.conf

server

}3.檢查配置重啟

[root@web02 /etc/nginx/conf.d]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@web02 /etc/nginx/conf.d]# systemctl restart nginx

1.第乙個配置

[root@web02 /etc/nginx/conf.d]# cat mali.conf

server

}2.第二個配置

[root@web02 /etc/nginx/conf.d]# cat tank.conf

server

}3.檢查配置並重啟

[root@web02 /etc/nginx/conf.d]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@web02 /etc/nginx/conf.d]# systemctl restart nginx

4.訪問測試

1)訪問

2)訪問

1.第乙個配置

[root@web02 /etc/nginx/conf.d]# vim mali.conf

server

}2.第二個配置

[root@web02 /etc/nginx/conf.d]# vim tank.conf

server

}3.檢查並重啟

[root@web03 /etc/nginx/conf.d]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@web03 /etc/nginx/conf.d]# systemctl restart nginx

4.配置本地hosts

c:\windows\system32\drivers\etc\hosts

10.0.0.8 www.mali.com

10.0.0.8 www.tank.com

5.訪問測試

Nginx虛擬主機配置

0.nginx簡介 nginx engine x 是乙個高效能的 http 和 反向 伺服器,也是乙個 imap pop3 smtp 伺服器。nginx 已經因為它的穩定性 豐富的功能集 示例配置檔案和低系統資源的消耗而聞名了。1.nginx使用注意事項 2.nginx相關檔案 3.nginx虛擬主...

nginx虛擬主機配置

就是在一台伺服器啟動多個 如何區分不同的 1 網域名稱不同 2 埠不同 乙個server節點就是乙個虛擬主機,可以配置多個server,配置多個虛擬主機,html是nginx安裝目錄下的html目錄。乙個網域名稱對應乙個ip位址,乙個ip位址可以被多個網域名稱繫結。本地測試可以修改hosts檔案。修...

nginx虛擬主機配置

虛擬主機的配置有多種 一 color green b 基於ip的虛擬主機 b color 二 color green b 基於埠的虛擬主機 b color 三 color green b 基於網域名稱的虛擬主機 b color 對於nginx要實現虛擬主機,通過nginx.cnf中的server進行...