新聞中心
Nginx 虛擬機(jī)使用是廣大管理員需要掌握的相關(guān)問題,在使用中相關(guān)的問題需要我們不斷學(xué)習(xí)和掌握,下面我們就詳細(xì)的看看有關(guān)的問題。在Nginx 虛擬機(jī)中用多個(gè)子域名,每個(gè)子域名到不同的目錄。

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供臨澧網(wǎng)站建設(shè)、臨澧做網(wǎng)站、臨澧網(wǎng)站設(shè)計(jì)、臨澧網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、臨澧企業(yè)網(wǎng)站模板建站服務(wù),十多年臨澧做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
如:
- http {
- server {
- listen 80;
- server_name a.chenlb.com;
- access_log logs/a.access.log main;
- server_name_in_redirect off;
- location / {
- index index.html;
- root /home/www/host_a/;
- }
- }
- server {
- listen 80;
- server_name b.chenlb.com;
- access_log logs/b.access.log main;
- server_name_in_redirect off;
- location / {
- index index.html;
- root /home/www/host_b/;
- }
- }
- }
- http {
- server {
- listen 80;
- server_name a.chenlb.com;
- access_log logs/a.access.log main;
- server_name_in_redirect off;
- location / {
- index index.html;
- root /home/www/host_a/;
- }
- }
- server {
- listen 80;
- server_name b.chenlb.com;
- access_log logs/b.access.log main;
- server_name_in_redirect off;
- location / {
- index index.html;
- root /home/www/host_b/;
- }
- }
- }
結(jié)果發(fā)現(xiàn)用 b.chenlb.com 還是指到 host_a 目錄。后來看了官方示例:http://wiki.Nginx.org/NginxVirtualHostExample,提到有個(gè) default 的匹配,如:
- http {
- server {
- listen 80 default;
- server_name _;
- access_log logs/default.access.log main;
- server_name_in_redirect off;
- location / {
- index index.html;
- root /var/www/default/htdocs;
- }
- }
- }
- http {
- server {
- listen 80 default;
- server_name _;
- access_log logs/default.access.log main;
- server_name_in_redirect off;
- location / {
- index index.html;
- root /var/www/default/htdocs;
- }
- }
- }
加上這個(gè) default 就可使 a.chenlb.com 和 b.chenlb.com 正常工作了。以上就是Nginx 虛擬機(jī)的詳細(xì)介紹。
分享題目:Nginx虛擬機(jī)如何安裝和使用
文章網(wǎng)址:http://www.5511xx.com/article/dpihgce.html


咨詢
建站咨詢
