zoukankan      html  css  js  c++  java
  • Nginx作为静态内容服务器(Windows环境)

    1、简单安装

      1)下载

    http://nginx.org/en/download.html

      2)解压后的路径

    E:Study
    ginx
    ginx-1.7.6

      3)执行nginx.exe,访问http://localhost ,出现Welcome to nginx!欢迎内容,安装成功。

      4)在安装路径的logs目录下,会自动生成一个nginx.pid文件,文件内容就是nginx的主进程pid。

    2、简单使用命令

    nginx -s stop    快速停止
    nginx -s quit    安全退出(会处理完正在进行的请求)
    nginx -s reload    修改了nginx的配置文件后执行该命令生效
    nginx -s reopen    重打开日志文件    

    3、静态内容服务器

      访问html文件时,让nginx映射到/data/html路径下;访问图片文件时,让nginx映射到/data/image路径下。

      1)创建data目录,然后在data目录下分别插件html目录和image目录。

      2)在html目录中放入index.html、hello.html文件

      3)在image目录中放入1.jpg、2.jpg两张图片

      4)配置nginx.conf

        在http节点内的server节点中进行配置。

    location / {
                #指定根目录
                root   E:/Study/nginx/nginx-1.7.6/data/html;
                #指定首页
                index  index.html;
            }
            
    location /image/ {
                #指定根目录
                root   E:/Study/nginx/nginx-1.7.6/data;
    }

      5)请求 http://localhost/image/1.jpg 时,Nginx自动响应 http://localhost/data/image/1.jpg

        请求 http://localhost/hello.html 时,Nginx自动响应 http://localhost/data/html/hello.html

  • 相关阅读:
    JS 博客园鼠标点击效果
    安卓socket聊天
    抖音C#版,自己抓第三方抖音网站
    C#网易云音乐播放器
    反编译APK
    Raspberry Config.txt 介绍
    Raspberry U盘操作
    排序(I)
    未解决问题:
    CocoaPod 问题(I)
  • 原文地址:https://www.cnblogs.com/luxh/p/4054341.html
Copyright © 2011-2022 走看看