標籤:
Nginx 基於 ip 的虛擬機器主機配置{#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 基於連接埠的虛擬機器主機配置{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}基於名稱的虛擬機器主機配置詳解{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#重啟 nginx 服務[[email protected] conf.d]# systemctl restart nginx.serviceworkstation 用戶端測試[[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 80 default;#在監聽連接埠號碼後邊添加 default 欄位,即代表該虛擬機器主機為預設虛擬機器主機location / {root /usr/share/nginx/err.com;index index.html index.htm;}#建立該虛擬機器主機網頁檔案存放目錄和首頁檔案,一般首頁檔案中即為報錯資訊[[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#重啟 nginx 服務[[email protected] conf.d]# systemctl restart nginx.service(4)workstation 用戶端測試}
零基礎學習雲端運算及大資料DBA叢集架構師【企業級營運技術及實踐項目2015年1月27日周三】