Nginx IP-based virtual host configuration {#serverb (1)/ETC/NGINX/CONF.D/*[[email protected] conf.d]# vim ip.confserver {listen 192.168.1.88:80; Root 88.com; Index index.html; }server {Listen 192.168.1.87:80; Root 87.com; Index index.html; }[[email protected] ~]# ifconfig eth1:0 192.168.1.88[[email protected] ~]# ifconfig eth1:1 192.168.1.87[[email protected] ~]# mkdir/usr/local/ Nginx/88.com[[email protected] ~]# echo ' This is 88.com ' >/usr/local/nginx/88.com/index.html[[email Protected] ~]# mkdir/usr/local/nginx/87.com[[email protected] ~]# echo ' This is 87.com ' >/usr/local/nginx/87. Com/index.html}nginx Port-based virtual host configuration {server {listen 80; Root 80.com;} server {listen 8080; Root 8080.com;} [[email protected] ~]# mkdir/usr/local/nginx/80.com[[email protected] ~]# mkdir/usr/local/nginx/8080.com [[email protected] ~]# echo ' This is 80.com ' >/usr/local/nginx/80.com/index.html[[email protected] ~]# Echo ' This is 8080.com ' >/usr/local/nginx/8080.com/index.html} Detailed name-based virtual host configuration {1.www.dabao.comwww.booboo.com[[email protected] conf.d]# Pwd/etc/nginx/conf.d[[email protected] conf.d]# CP default.conf www.booboo.com.conf[[email protected] conf.d]# CP default.conf www.dabao.com.conf[[email protected] conf.d]# vim Www.booboo.com.confserver {Listen 80; server_name www.booboo.com; Location/{root/usr/share/nginx/booboo.com; Index index.html index.htm; }}[[email protected] conf.d]# vim www.dabao.com.confserver {Listen 80; server_name www.dabao.com; root/usr/share/nginx/dabao.com; Index index.html index.htm; }[[email protected] conf.d]# mkdir/usr/share/nginx/dabao.com[[email protected] conf.d]# mkdir/usr/share/ Nginx/booboo.com[[email protected] conf.d]# echo hi,booboo >/usr/share/nginx/booboo.com/index.html[[email protected] conf.d]# echo hi,dabao>/usr/share/nginx/dabao.com/index.html# restart Nginx service [[email protected] conf.d]# systemctl restart nginx.serviceworkstation client test [[email protected] ~]# echo 172.25.15.10 www.dabao.com >>/etc/hosts[[email protected] ~]# echo 172.25.15.10 www.booboo.com > >/etc/hosts2.server_namemail.dabao.comnews.dabao.comwww.news.dabao.comwww.sports.dabao.com[[email Protected] conf.d]# vim www.booboo.com.confserver {Listen 80; server_name ~www\. *\.booboo\.com; Location/{root/usr/share/nginx/booboo.com; Index index.html index.htm; }}[[email protected] conf.d]# vim www.dabao.com.confserver {Listen 80; server_name *.dabao.com; root/usr/share/nginx/dabao.com; Index index.html index.htm; }3.locationwww.booboo.com/news.html[[email protected] conf.d]# cat Www.booboo.com.confserver {Listen 80; server_name ~www.*\.booboo\.com; Location/{root/usr/share/nginx/booboo.com; Index index.html Index.htm } location ~/news.html{root/usr/share/nginx/dabao.com; Index index.html index.htm; }}4.80 default[[email protected] conf.d]# cp default.conf err.com.conf[[email protected] conf.d]# vim Err.com.confserver {listen; #在监听端口号后边添加 the default field, which means that the virtual host is the defaults virtual host location/{root/usr/share/nginx/err.com; Index index.html index.htm;} #创建该虚拟主机网页文件存放目录和首页文件, the general home file is the error message [[email protected] conf.d]# mkdir/usr/share/nginx/err.com[[email Protected] conf.d]# echo cannot found this virtual host name >/usr/share/nginx/err.com/index.html# restart nginx service [[EMAIL&N Bsp;protected] conf.d]# systemctl restart Nginx.service (4) Workstation client Test}
0 Basic Learning Cloud computing and Big Data DBA cluster Architect "enterprise-level operation and maintenance technology and practice Project January 27, 2015 Wednesday"