nginx基于端口的虚拟主机实战
2017-08-20 11:21
621 查看
nginx基于端口的虚拟主机,就是以端口来区分。只要端口不同就可以。
实战1: 端口不一样,域名不一样。编辑nginx.conf配置文件,不通域名修改为不通端口,listen 80 81 82三个端口
1.2.1 windows的hosts文件添加本地dns解析
10.0.0.8 www.etiantian.org bbs.etiantian.org blog.etiantian.org
1.2.2 验证
分别在windows的ie中输入地址www.etiantian.org:80
bbs.etiantian.org:81 blog.etiantian.org:82 这三个网址,看是否有对应的内容,有就说明配置成功了。(原理就是域名解析成ip,ip再对应端口)
实战2: nginx站点都用一个域名www.etiantian.org,但是端口分别是80、81、82
在windows的ie中分别输入网址:www.etiantian.org:80 www.etiantian.org:81
www.etiantian.org:82 看是否显示对应的站点首页内容。下图已显示对应的站点首页内容了。
实战1: 端口不一样,域名不一样。编辑nginx.conf配置文件,不通域名修改为不通端口,listen 80 81 82三个端口
[root@web01 conf]# pwd /application/nginx/conf [root@web01 conf]# cat nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.etiantian.org; location / { root html/www; index index.html index.htm; } } server { listen 81; server_name bbs.etiantian.org; location / { root html/bbs; index index.html index.htm; } } server { listen 82; server_name blog.etiantian.org; location / { root html/blog; index index.html index.htm; } } }1.1 查看nginx服务是否启动(查看进程和端口都可以)
[root@web01 conf]# ps -ef|grep nginx root 1437 1313 0 10:36 pts/1 00:00:00 grep nginx如上查看nginx服务对应的进程不存在就说明nginx服务没有启动,启动nginx服务。
[root@web01 conf]# /application/nginx/sbin/nginx1.2 验证
1.2.1 windows的hosts文件添加本地dns解析
10.0.0.8 www.etiantian.org bbs.etiantian.org blog.etiantian.org
1.2.2 验证
分别在windows的ie中输入地址www.etiantian.org:80
bbs.etiantian.org:81 blog.etiantian.org:82 这三个网址,看是否有对应的内容,有就说明配置成功了。(原理就是域名解析成ip,ip再对应端口)
实战2: nginx站点都用一个域名www.etiantian.org,但是端口分别是80、81、82
[root@web01 conf]# pwd /application/nginx/conf [root@web01 conf]# cat nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.etiantian.org; location / { root html/www; index index.html index.htm; } } server { listen 81; server_name www.etiantian.org; location / { root html/bbs; index index.html index.htm; } } server { listen 82; server_name www.etiantian.org; location / { root html/blog; index index.html index.htm; } } }2.1 检查nginx语法,并平滑重启
[root@web01 conf]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 conf]# /application/nginx/sbin/nginx -s reload2.2 验证
在windows的ie中分别输入网址:www.etiantian.org:80 www.etiantian.org:81
www.etiantian.org:82 看是否显示对应的站点首页内容。下图已显示对应的站点首页内容了。
相关文章推荐
- Linux实战第八篇:CentOS7.3下Nginx虚拟主机配置实战(基于端口)
- Nginx基于IP,端口,域名配置虚拟主机
- nginx学习笔记之基于端口的虚拟主机基于主机名的虚拟主机root、alias、index配置
- linux下nginx实现虚拟主机(3种方法:基于域名、基于端口、基于ip地址)
- Linux实战第五篇:RHEL7.3下Nginx虚拟主机配置实战(基于别名)
- nginx基于域名的虚拟主机实战配置
- nginx基于域名的虚拟主机配置实战
- nginx配置基于端口和基于IP的虚拟主机
- nginx基于端口的虚拟主机:
- Linux实战第七篇:CentOS7.3下Nginx虚拟主机配置实战(基于IP)
- nginx基于ip的虚拟主机实战
- Linux实战第六篇:CentOS7.3下Nginx虚拟主机配置实战(基于域名)
- 编译安装Nginx基于虚拟主机、端口,Openssl
- Centos中Nginx部署基于IP的虚拟主机
- 在Nginx中部署基于IP的虚拟主机
- apache基于域名和端口的虚拟主机
- Linux 基于端口的虚拟主机配置
- apache服务器基于ip以及基于端口的虚拟主机访问
- Apache 的修改端口,虚拟主机搭建基于网站加密和常见问题解答
- Nginx配置多个基于域名的虚拟主机+实验环境搭建+测试