#user  nobody;    登录用户

worker_processes  1;   nginx开启的进程数,一般开启一个就足够,多开几个work进程,可以减少机器io带来的影响,在一般情况下

开启4个或者8个,多开无意

 

#error_log  logs/error.log;  错误日志目录

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;   记录nginx pid文件的参数

 

 

events {  每个work进程可以处理的连接数 并发连接数

    worker_connections  1024;  如果网站访问量过大,已经超过1024并发数,那么就要修改worker_connecions,这个植越大

并发数也就大,按照实际情况决定,不能设置过多,否则会造成IO负载量过大

}

 

 

http {

    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        on;

    #tcp_nopush     on;  开启后会产生一个响应头部信息产生独立的数据包发送,一个响应头一个包

 

    #keepalive_timeout  0;  保持连接的超时时间

    keepalive_timeout  65;

 

    #gzip  on; 是否采用压缩

    server {

        listen  80;

        server_name     www.xiaohu.com;

        location / {

        root    html/xiaohu;

        index   index.html  index.htm;

}

}

    server {  定义虚拟机

        listen       80;  服务器监听端口

        server_name  localhost;  访问域名

 

        #charset koi8-r;  编码格式

 

        #access_log  logs/host.access.log  main;  虚拟主机访问日志

 

        location / {  url匹配

            root   html;  网页路径

            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;

        }

 

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {  php页面

        #    proxy_pass   http://127.0.0.1;   反向代理模块  反向代理地址

        #}

 

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #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

        #

        #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 server

    #

    #server {

    #    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;

    #    }

    #}

 

}