新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Nginx虛擬機如何安裝和使用
Nginx 虛擬機使用是廣大管理員需要掌握的相關問題,在使用中相關的問題需要我們不斷學習和掌握,下面我們就詳細的看看有關的問題。在Nginx 虛擬機中用多個子域名,每個子域名到不同的目錄。

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供臨澧網(wǎng)站建設、臨澧做網(wǎng)站、臨澧網(wǎng)站設計、臨澧網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、臨澧企業(yè)網(wǎng)站模板建站服務,十多年臨澧做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。
如:
- 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,提到有個 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;
- }
- }
- }
加上這個 default 就可使 a.chenlb.com 和 b.chenlb.com 正常工作了。以上就是Nginx 虛擬機的詳細介紹。
分享題目:Nginx虛擬機如何安裝和使用
鏈接分享:http://www.fisionsoft.com.cn/article/dpihgce.html


咨詢
建站咨詢
