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

  • 相关阅读:
    Android Static分析
    hdoj 1285 确定比赛名次 【拓扑排序】
    Sqoop2安装记录
    Activiti源代码分析
    SpringBoard 无法启动应用程序(错误:-3)
    关于public、private、protected、internal
    Java基础——Statement与PrepareStatement
    无password身份验证:安全、简单且部署高速
    说说Linux文件权限那些事儿
    Android中Service概述
  • 原文地址:https://www.cnblogs.com/luxh/p/4054341.html
Copyright © 2011-2022 走看看