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

}
相关推荐
hanniuniu1311 分钟前
详细解读,F5服务器负载均衡的技术优势
运维·服务器·负载均衡
鱼饼6号24 分钟前
Prometheus 上手指南
linux·运维·centos·prometheus
m0_609000422 小时前
向日葵好用吗?4款稳定的远程控制软件推荐。
运维·服务器·网络·人工智能·远程工作
小安运维日记3 小时前
Linux云计算 |【第四阶段】NOSQL-DAY1
linux·运维·redis·sql·云计算·nosql
m0_741768857 小时前
使用docker的小例子
运维·docker·容器
学习3人组7 小时前
CentOS 中配置 OpenJDK以及多版本管理
linux·运维·centos
厨 神8 小时前
vmware中的ubuntu系统扩容分区
linux·运维·ubuntu
Karoku0668 小时前
【网站架构部署与优化】web服务与http协议
linux·运维·服务器·数据库·http·架构
geek_Chen018 小时前
虚拟机共享文件夹开启后mnt/hgfs/下无sharefiles? --已解决
linux·运维·服务器
(⊙o⊙)~哦8 小时前
linux 解压缩
linux·运维·服务器