基于域名的虛擬主機 : 不同的域名 相同的IP
基于埠的虛擬主機 : 不使用域名、IP來區分,而是用不同的TCP埠號
基于IP地址的虛擬主機 : 不同的域名 不同的IP ( 需要加網路介面 )
安裝nginx (這里是yum裝)
[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum -y install nginx
創建個測驗頁面
[root@localhost ~]# vim /usr/share/nginx/html/index.html
小紅花
~
修改組態檔 (基于埠)
[root@localhost ~]# vim /etc/nginx/nginx.conf
server {
listen 8080; #埠
location / {
root /usr/share/nginx/html;
index index.html;
}
}
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# curl 192.168.27.137:8080
小紅花
修改組態檔 (基于域名)
[root@localhost ~]# vim /etc/nginx/nginx.conf
server {
listen 80;
location / {
server_name www.hong.com; #域名
root /usr/share/nginx/html;
index index.html;
}
}
[root@localhost ~]# systemctl restart nginx
[root@localhost ~]# vim /etc/hosts ##添加域名決議
192.168.27.137 www.hong.com
[root@localhost ~]# curl www.hong.com
小紅花
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/198520.html
標籤:其他
上一篇:如何安裝Centos5.6呢?
下一篇:嵌入式程式應用除錯
