LINUX运维学习之综合架构篇——nginx配置说明

目录结构:
/etc/logrotate.d/nginx :日志文件定时切割处理,nginx使用自动切割程序 logrotate(其配置文件是/etc/logrotate.conf)这个目录里的配置也会被logrotate加载。
/etc/nginx 配置文件
/etc/nginx/conf.d 配置文件
/etc/nginx/conf.d/default.conf 配置文件
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types 定义nginx可以处理哪些媒体资源类型
/etc/nginx/modules
/etc/nginx/nginx.conf 配置文件
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx
/usr/lib64/nginx/modules
/usr/libexec/initscripts/legacy-actions/nginx
/usr/libexec/initscripts/legacy-actions/nginx/check-reload
/usr/libexec/initscripts/legacy-actions/nginx/upgrade
/usr/sbin/nginx 命令文件
/usr/sbin/nginx-debug
/usr/share/doc/nginx-1.18.0
/usr/share/doc/nginx-1.18.0/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx
/usr/share/nginx/html 站点目录
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/var/cache/nginx
/var/log/nginx 日志文件

1、/etc/nginx/nginx.conf

[root@localhost nginx]# cat nginx.conf 
user  nginx;  定义管理worker服务的用户
worker_processes  1;    定义几个worker进程,一般配置为CPU核数。master_processes管理服务正常运行,worker_processes正真处理用户请求(杀死worker进程不会正真停止nginx服务。)
error_log  /var/log/nginx/error.log warn; 错误日志
pid        /var/run/nginx.pid;            记录进程ID

#########################################################
events {
    worker_connections  1024; 定义一个worker进程可以同时接受的请求数量
}

#########################################################

http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main; 定义日志路径并引用上述格式
    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;  连接超时时间
    #gzip  on;
    include /etc/nginx/conf.d/*.conf;  加载配置文件
}

2、/etc/nginx/conf.d/default.conf

server {              网站的配置,一个server就是一个网站,也叫虚拟主机
    listen       80;   监听端口
    server_name  localhost;   指定网站域名
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    location / {
        root   /usr/share/nginx/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   /usr/share/nginx/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;
    #}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值