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

}
相关推荐
HYI29 分钟前
小公司前端多分支测试太痛苦?我自己写了个轻量 CLI
nginx·vite
杭州泽沃电子科技有限公司1 小时前
告别翻山越岭!智能监拍远程守护输电线路安全
运维·人工智能·科技·安全
长臂人猿2 小时前
JVM常用工具:jstat、jmap、jstack
linux·运维·jvm
timeweaver5 小时前
深度解析 Nginx 前端 location 配置与优先级:你真的用对了吗?
前端·nginx·前端工程化
HWL56796 小时前
“preinstall“: “npx only-allow pnpm“
运维·服务器·前端·javascript·vue.js
门前灯7 小时前
Linux系统之iprconfig 命令详解
linux·运维·服务器·iprconfig
忧郁的橙子.8 小时前
三、k8s 1.29 之 安装2
linux·运维·服务器
huangyuchi.8 小时前
【Linux系统】动静态库的制作
linux·运维·服务器·动态库·静态库·库的简单制作
闻不多8 小时前
用llamaindex搭建GAR遇到400
android·运维·服务器
jim写博客9 小时前
Linux进程概念(四)环境地址变量
linux·运维·服务器