虹口专业做网站,网站建设模板推广,广东住房和城乡建设部网站,网站做直播吗开始前请确保selinux关闭#xff0c;否则当配置完虚拟主机后#xff0c;尽管权限或者网站目录都正确#xff0c;访问的结果也是403 nginx的虚拟主机有三种方式#xff1a; 一、基于域名的虚拟主机 #xff08;1#xff09;创建对应的web站点目录以及程序代码 [rootweb01 … 开始前请确保selinux关闭否则当配置完虚拟主机后尽管权限或者网站目录都正确访问的结果也是403 nginx的虚拟主机有三种方式 一、基于域名的虚拟主机 1创建对应的web站点目录以及程序代码 [rootweb01 ~]# mkdir /data/www/{game,video}
[rootweb01 ~]# echo game /data/www/game/index.html
[rootweb01 ~]# echo video /data/www/video/index.html 2配置不同域名的虚拟主机 [rootweb01 ~]# cat /etc/nginx/conf.d/game.conf
server {listen 80;server_name game.com;root /data/www/game;index index.html;...
}
[rootweb01 ~]# cat /etc/nginx/conf.d/video.conf
server {...listen 80;server_name video.com;root /data/www/video;index index.html;
}配置完虚拟主机后最好重启或重载nginx服务 3修改hosts文件进行访问测试 vim /etc/hosts
127.0.0.1 game.com video.comcurl game.comgamecurl video.comvideo 二、基于IP的虚拟主机 1、基于多网卡多IP的方式 server {...listen 10.0.0.10:80;...
}server {...listen 10.0.0.11:80;...
} 2、基于单网卡多IP的方式 #添加一个IP
[rootweb01 ~]# ip addr add 10.0.0.11/24 dev eth0# 虚拟机配置方案
[rootweb01 ~]# cat /etc/nginx/conf.d/addr1.conf
server {...listen 10.0.0.10:80;...
}[rootweb01 ~]# cat /etc/nginx/conf.d/addr2.conf
server {...listen 10.0.0.11:80;...
} 三、基于端口的虚拟主机 #仅修改listen监听端口即可, 但不能和系统端口出现冲突[rootweb01 ~]# cat /etc/nginx/conf.d/port1.conf
server {...listen 80;...
}[rootweb01 ~]# cat /etc/nginx/conf.d/port2.conf
server {...listen 81;...
}[rootweb01 ~]# cat /etc/nginx/conf.d/port3.conf
server {...listen 82;...
} 转载于:https://www.cnblogs.com/Smbands/p/11409663.html