nginx核心配置文件结构(cat nginx.conf)

文章目录

  • [1、whereis nginx](#1、whereis nginx)
  • [2、cd /usr/local/nginx/conf/](#2、cd /usr/local/nginx/conf/)
  • [3、cat nginx.conf](#3、cat nginx.conf)

从前面的内容学习中,我们知道Nginx的核心配置文件默认是放
在/usr/local/nginx/conf/nginx.conf,这一节,我们就来学习下
nginx.conf的内容和基本配置方法。
读取Nginx自带的Nginx配置文件,我们将其中的注释部分【学习一个技
术点就是在Nginx的配置文件中可以使用#来注释】删除掉后,就剩下下
面内容:

1、whereis nginx

bash 复制代码
[root@localhost ~]# whereis nginx
nginx: /usr/local/nginx

2、cd /usr/local/nginx/conf/

bash 复制代码
[root@localhost conf]# cd /usr/local/nginx/conf/
[root@localhost conf]# ll
总用量 68
-rw-r--r--. 1 root root 1077 7月  11 18:53 fastcgi.conf
-rw-r--r--. 1 root root 1077 7月  11 18:53 fastcgi.conf.default
-rw-r--r--. 1 root root 1007 7月  11 18:53 fastcgi_params
-rw-r--r--. 1 root root 1007 7月  11 18:53 fastcgi_params.default
-rw-r--r--. 1 root root 2837 7月  11 18:53 koi-utf
-rw-r--r--. 1 root root 2223 7月  11 18:53 koi-win
-rw-r--r--. 1 root root 5231 7月  11 18:53 mime.types
-rw-r--r--. 1 root root 5231 7月  11 18:53 mime.types.default
-rw-r--r--. 1 root root 2656 7月  11 18:53 nginx.conf
-rw-r--r--. 1 root root 2656 7月  11 18:53 nginx.conf.default
-rw-r--r--. 1 root root  636 7月  11 18:53 scgi_params
-rw-r--r--. 1 root root  636 7月  11 18:53 scgi_params.default
-rw-r--r--. 1 root root  664 7月  11 18:53 uwsgi_params
-rw-r--r--. 1 root root  664 7月  11 18:53 uwsgi_params.default
-rw-r--r--. 1 root root 3610 7月  11 18:53 win-utf

3、cat nginx.conf

c 复制代码
[root@localhost conf]# cat nginx.conf

#user  nobody;
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 {
    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  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            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$ {
        #    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;
    #    }
    #}

}
相关推荐
ladymorgana1 分钟前
【Docker】如何设置 `wiredTigerCacheSizeGB` 和 `resources.limits.memory`
运维·docker·容器
代码讲故事1 小时前
多种方法实现golang中实现对http的响应内容生成图片
开发语言·chrome·http·golang·图片·快照·截图
chanalbert1 小时前
CentOS系统新手指导手册
linux·运维·centos
星宸追风1 小时前
Ubuntu更换Home目录所在硬盘的过程
linux·运维·ubuntu
制造数字化方案研究院2 小时前
59页|PPT|华为集成服务交付ISD业务变革总体方案:业务规则、流程、IT、组织及度量“四位一体”的管理体系
运维·华为
热爱生活的猴子2 小时前
Poetry 在 Linux 和 Windows 系统中的安装步骤
linux·运维·windows
myloveasuka2 小时前
[Linux]内核如何对信号进行捕捉
linux·运维·服务器
渲吧-云渲染2 小时前
云渲染时,电脑能关机吗?关键阶段操作指南
运维·服务器·电脑
m0_694845572 小时前
服务器需要备案吗?在哪些地区需要备案?
linux·运维·服务器·云计算
小眼睛FPGA3 小时前
【RK3568+PG2L50H开发板实验例程】Linux部分/FPGA dma_memcpy_demo 读写案例
linux·运维·科技·ai·fpga开发·gpu算力