NAMP安装(二) Nginx的配置文件信息

来源:互联网 发布:在线数据分析软件 编辑:程序博客网 时间:2024/06/06 13:39
#--注释  user username[groupname] 就是启动worker进程的用户 #user  nobody;#--注释  worker进程的数量,最好和cpu核数相同worker_processes  1;#--注释 错误日志  日志保存的位置  错误级别#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#--注释 主程序的进程号保存的位置#pid        logs/nginx.pid;#--注释 并发的设置数 ,一定是峰值的最大数进行设置events {    worker_connections  1024;}#--注释 http请求的相关配置http {    #--注释 include包含 ,这里是包含进入mime.types 这个文件    #--注释 default_type 设置默认类型为二进制流的方式返回    include       mime.types;    default_type  application/octet-stream;        #--注释 定义日志的格式,起名为main      #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;        #--注释 开启linux的内核功能 使用内核中的sendfile系统调用    #--注释 参考的网址: http://blog.csdn.net/hairetz/article/details/6549306    sendfile        on;    #--注释 在数据包进行发送的时候,有多个数据包的时候,会进行积累,当满足要发送的大小的时候才进行发送    #--注释 这是一种算法,可以解决当有多个小包,只发送1个字节的数据,但是却携带40字节的头信息(20ip,20tcp)    #--注释 当大型网站如果发生上面所说问题,会照成资源浪费,访问速度变慢,浪费流量跟带宽    #--注释 开启tcp_nopush 这个功能 必须开启 sendfile ,他妈默认都是开启的    #tcp_nopush     on;    #--注释 TCP会话时候的保持连接时长       #keepalive_timeout  0;    keepalive_timeout  65;        #--注释 开启压缩,下面是压缩的代码    gzip  on;    gzip_http_version 1.0;    gzip_disable 'MSIE [1-6]\.';    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg;    #gzip_comp_level 2; #--注释 配置压缩的级别 是1-10,我们使用默认的就行了    #--注释 虚拟主机的配置      server {   #--注释 监听的端口  然后是域名        listen       80;        server_name  localhost;                #--注释 配置字符集         charset utf-8;      #--注释 访问日志 日志地址 日志格式        #access_log  logs/host.access.log  main;               #--注释 当访问路径是/ 根目录时候的配置        location / {       #--注释 web站点根目录,一定是绝对路径,开发中,一般是共享目录            root   /mnt/hgfs/www;            #--注释 默认的主页配置            index  index.php index.html index.htm;        }               #--注释 配置图片缓存        location ~ \.(gif|png|jpg|jpeg)$ {      #--注释 配置缓存30天 h是小时       expires 30d;    }               #--注释 发生404错误的时候 指向的页面        #error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #--注释 发生服务器内部错误的时候,路由指向 /50x.html         error_page   500 502 503 504  /50x.html;   #--注释 路由/50x.html的相关配置        location = /50x.html {            root   html;        }                              # proxy the PHP scripts to Apache listening on 127.0.0.1:80        #--注释 如果是已.php结尾的,开启代理吗,指向proxy_pass 指向的服务器        #--注释 如果有多个服务器,那么用 , 隔开        #location ~ \.php$ {        #    proxy_pass   http://127.0.0.1;        #}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #--注释 当路由是已.php结尾的 配置相关信息        location ~ \.php$ {        #--注释  网站的根目录            root           /mnt/hgfs/www;        #--注释 fastcgi 是web架构的意思,pass过滤,其实就是php-fpm服务器            fastcgi_pass   127.0.0.1:9000;        #--注释 默认访问的主页            fastcgi_index  index.php;        #--注释 定义一个常量参数 脚本的文件名            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        #   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;    #    }    #}}

原创粉丝点击