共计 2357 个字符,预计需要花费 6 分钟才能阅读完成。
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