练习:定义四个虚拟主机,混合使用三种类型的虚拟主机;
仅开放给来自于本地网络中的主机访问;
[root@node1 ~]# vim /etc/nginx/nginx.conf user nginx; //在此行后添加下面2行 worker_processes auto; worker_cpu_affinity 0000 0010 0100 1000; events { worker_connections 1024; //在此行后添加下面1行 accept_mutex on; } [root@node1 ~]# vim /etc/nginx/conf.d/default.conf //定义了4个虚拟主机 基于IP的、基于端口的、基于FQDN的 server { server_name www.gm1.com; listen 10.1.43.1:80; root "/www/gm1"; } server { server_name www.gm2.com; listen 10.1.43.11:80; root "/www/gm2"; } server { server_name www.gm3.com; listen 10.1.43.1:8080; root "/www/gm3"; } server { server_name www.gm4.com; listen 10.1.43.1:80; root "/www/gm4"; } [root@node1 ~]# mkdir -pv /www/gm{1,2,3,4} [root@node1 ~]# for i in {1..4} ; do echo " > /www/gm$i/index.html ; done
原创文章,作者:megedugao,如若转载,请注明出处:http://www.178linux.com/53612