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

}
相关推荐
zhaotiannuo_19982 小时前
渗透测试之docker
运维·docker·容器
王正南3 小时前
kali-linux 虚拟机连接安卓模拟器
android·linux·运维·虚拟机连接模拟器·安卓模拟器,linux虚拟机
三不原则3 小时前
故障案例:容器启动失败排查(AI运维场景)——从日志分析到根因定位
运维·人工智能·kubernetes
吳所畏惧3 小时前
Linux环境/麒麟V10SP3下离线安装Redis、修改默认密码并设置Redis开机自启动
linux·运维·服务器·redis·中间件·架构·ssh
yueguangni4 小时前
sysstat 版本 10.1.5 是 CentOS 7 的默认版本,默认情况下确实不显示 %wait 字段。需要升级到新版sysstat
linux·运维·centos
funfan05174 小时前
【运维】MySQL数据库全量备份与恢复实战指南:从入门到精通
运维·数据库·mysql
-dcr4 小时前
49.python自动化
运维·python·自动化
Benny的老巢4 小时前
Mac上用XAMPP搭建局域网可访问的开发环境,让局域网内其他设备通过域名访问
nginx·macos·apache·xampp·php开发环境
萧曵 丶5 小时前
Linux 业务场景常用命令详解
linux·运维·服务器
乾元6 小时前
ISP 级别的异常洪泛检测与防护——大流量事件的 AI 自动识别与响应工程
运维·网络·人工智能·安全·web安全·架构