Nginx配置文件服务管理

Nginx配置文件服务管理

cd /usr/local/nginx/conf/nginx.conf
   /usr/local/nginx/conf/nginx.conf.default

1,event 网络模型的定义

event{

网络定义模型

}

2,http的配置

http{ 
    网站整体环境配置
    server{                     //--server--一个可以访问的网站
        一个可以访问的web服务器   //--server--一般在这里修改
    }                           //--server--绑定虚拟主机,多加几个server即可
}

3,配置文件详情

[root@iZwz9h901rvv69020rk7fsZ conf]# vim nginx.conf


    user  www www;
    #是nginx服务的伪用户,伪用户组
    worker_processes auto;
    #启动进程,通常设置成cup数量相等,相当于cpu的个数
    error_log  /home/wwwlogs/nginx_error.log  crit;
    #错误日志
    pid        /usr/local/nginx/logs/nginx.pid;
    #主进程pid保存文件
    google_perftools_profiles /tmp/tcmalloc;

    #Specifies the value for maximum file descriptors that can be opened by this process.
    worker_rlimit_nofile 51200;
    #文件描述符的数量
    events
        {
            use epoll;
            #网络I/O模型
            worker_connections 51200
            #工作进程最大允许的连接数
        }

    http
        {
            include       mime.types;
            default_type  application/octet-stream;
            #设定mine类型,文件传送类型由mine.type文件定义
            server_names_hash_bucket_size 128;
            #保存服务器名字的hash表大小
            client_header_buffer_size 32k;
            #客户端请求头部缓冲区大小
            large_client_header_buffers 4 32k;
            #最大客户端头缓冲大小
            client_max_body_size 50m;
            #客户端最大上传文件大小
            sendfile   on;
            # 控制异步传输
            tcp_nopush on;
            # 控制异步传输
            keepalive_timeout 60;
            #连接超时时间
            tcp_nodelay on;
            #禁用nagle算法,就是不缓存数据

            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 300;
            fastcgi_buffer_size 64k;
            fastcgi_buffers 4 64k;
            fastcgi_busy_buffers_size 128k;
            fastcgi_temp_file_write_size 256k;
            #fastcgi 设置,主要是提高了fastcgi性能
            gzip on;
            gzip_min_length  1k;
            gzip_buffers     4 16k;
            gzip_http_version 1.1;
            gzip_comp_level 2;
            gzip_vary on;
            gzip_proxied   expired no-cache no-store private auth;
            gzip_disable   "MSIE [1-6]\.";
            #开启gzip网络压缩

            #limit_conn_zone $binary_remote_addr zone=perip:10m;
            ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

            server_tokens off;
            #隐藏版本号,报错不会显示版本,比价安全
            access_log off;
            #nginx日志
            server
                {
                    listen 80 default_server;
                    #监听端口
                    #listen [::]:80 default_server ipv6only=on;
                    server_name www.lnmp.org;
                    #域名
                    index index.html index.htm index.php;
                    #默认网页文件名    
                    root  /data/www;
                    #网页主目录
                    #error_page   404   /404.html;
                    autoindex on
                    #开启文件列表功能
                    include enable-php.conf;
                    #一下是nginx的网站核心配置,匹配等等,一般改动比较小
                    location /nginx_status
                    {
                        stub_status on;
                        access_log   off;
                    }

                    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                    {
                        expires      30d;
                    }

                    location ~ .*\.(js|css)?$
                    {
                        expires      12h;
                    }

                    location ~ /\.
                    {
                        deny all;
                    }

                    access_log  /home/wwwlogs/access.log;
                }
    include vhost/*.conf;
    }

4,虚拟主机

其实所谓绑定虚拟主机,就是在配置文件中加server
修改server中的server_name 域名
             root        根目录

注意:
    为了不让主配置文件太杂太乱,专门加了一个vhost文件夹提供虚拟主机服务
    可以在conf/vhost/下增加xxx(任意).conf文件单独写server来配置虚拟主机
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章