Nginx入门 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

虚拟主机示例


  Nginx做虚拟主机,尤其是仅仅支持纯静态-html,这是最简单的应用了,可以理解为一个仅支持静态页面的最简单的Web服务器。

  例子,同时支持两个虚拟主机(纯静态-html支持)的配置,我们只需要理改server段,如下:

server {
        listen       80;
        server_name  www.hubwiz.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
                      root   /root; 
                      index index.php index.html index.htm;  

        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
      }
server {
        listen       80;
        server_name  www.baidu.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
                      root   /root;     
                      index index.php index.html index.htm; 

        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}