#运行用户
#user nobody;
#启动进程,通常设置和cpu的数量相等
worker_processes 1;
#全局错误日志及pid文件路径
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#nginx工作模式及连接数上线
events {
#epoll是多路复用IO(I/O Multiplexing)中的一种方式,
#仅用于linux2.6以上内核,可以大大提高nginx的性能
use epoll
#单个后台的worker process进程的最大并发链接数
worker_connections 1024;
}
http {
#设定mime类型,类型由mime.types文件定义
include mime.types;
default_type application/octet-stream;
#设定日志格式
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
#sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,
#对于普通应用,必须设为 on,
#如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,
#以平衡磁盘与网络I/O处理速度,降低系统的uptime.
sendfile on;
#tcp_nopush on;
#连接超时时间
#keepalive_timeout 0;
keepalive_timeout 65;
#开启gzip压缩
#gzip on;
#设定虚拟主机的配置
server {
#监听80端口
listen 80;
#定义使用的域名 比如域名为www.limlhome.cn 这里就可以写为www.limlhome.cn
server_name localhost;
#设置字符集
#charset koi8-r;
#设置当前虚拟主机的访问日志路径
#access_log logs/host.access.log main;
#定义路径,如下为默认请求 例:http://www.besttest.cn/
location / {
# root 默认配置为html
root html;
# 语法:root path
# 如果一个请求的URI是/a.html时,web服务器将会返回服务器上的/www/root/user/a.html的文件。
# root /www/root/user/;
#
#首页索引文件的名称
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;
}
#静态文件,nginx自己完成处理
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
#过期30天,静态文件不怎么更新,过期可以设大一点,
#如果频繁更新,则可以设置得小一点。
expires 30d;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# 将PHP脚本请求全部转发到FastCGI处理,使用FastCGI默认配置
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#禁止访问 .htxxxxxx文件
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# Https配置
# HTTPS server
#
#server {
# https 使用443端口
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}