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

}
相关推荐
浮尘笔记2 小时前
Java Snowy框架CI/CD云效自动化部署流程
java·运维·服务器·阿里云·ci/cd·自动化
测试修炼手册8 小时前
[测试工具] 用 Codex 做测试实战:从需求分析到自动化用例落地
运维·自动化·需求分析
米高梅狮子8 小时前
03.网络类服务实践
linux·运维·服务器·网络·kubernetes·centos·openstack
IpdataCloud9 小时前
稳定的企业级IP数据接口怎么选?可用性指标+离线库高可用方案
运维·网络·tcp/ip
WebGIS开发10 小时前
地信职业百科②:GIS运维
运维·gis·就业·转行
淘矿人10 小时前
Claude辅助DevOps实践
java·大数据·运维·人工智能·算法·bug·devops
JiaWen技术圈10 小时前
nginx 安全响应头 介绍
运维·nginx·安全
IMPYLH10 小时前
Linux 的 unexpand 命令
linux·运维·服务器·bash
|_⊙11 小时前
Linux 文件知识 补充
linux·运维·服务器
十六年开源服务商13 小时前
2026服务器配置优化与WordPress运维实战指南
android·运维·服务器