你好,游客 登录 注册 搜索
背景:
阅读新闻

Nginx 访问静态html 文件方式

[日期:2016-04-13] 来源:Linux社区  作者:Linux [字体: ]

Nginx 访问静态html 文件方式

nginx 配置:

user  nginx nginx;
worker_processes  8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
worker_rlimit_nofile 65536;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  65536;
}


http {
    include      mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr [$time_local] $upstream_addr $upstream_status $upstream_response_time "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
    log_format cachelog '$time_local - $upstream_cache_status - Cache-Control:$upstream_http_cache_control - $request($status) - ';

    access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush    on;
    proxy_ignore_client_abort on;

    keepalive_timeout  65;
    #keepalive_timeout  1000;
    charset utf-8;
    gzip on;
    gzip_min_length 10k;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_types text/plain text/javascript application/javascript application/x-javascript text/css  application/xml application/octet-stream;
    gzip_vary on;
   
    server {

#被监听的端口号和网址


        listen      80;

        server_name  www.test.com;

        #charset koi8-r;

        access_log  logs/test_access.log  main;


        location / {

        #这个地方指定被访问的文件夹位置


            root  /data/test;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js)$ {
        root /data/test;
        expires 30d;
        }
    }

   
    #location ~ /purge(/.*){
    #    allow 192.168.0.0/16;
    #    deny all;
    #    proxy_cache_purge resource $host$1$is_args$args;
    #}
    }

更多Nginx相关教程见以下内容

CentOS 6.2实战部署Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm

使用Nginx搭建WEB服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm

CentOS 6.3下Nginx性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm

CentOS 6.3下配置Nginx加载ngx_pagespeed模块 http://www.linuxidc.com/Linux/2013-09/89657.htm

CentOS 6.4安装配置Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

Nginx安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm

Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

Nginx 的详细介绍请点这里
Nginx 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2016-04/130157.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款