LNMP架构应用实战——Nginx服务配置文件介绍

本人花费半年的时间总结的《Java面试指南》已拿腾讯等大厂offer,已开源在github ,欢迎star!

本文GitHub https://github.com/OUYANGSIHAI/JavaInterview 已收录,这是我花了6个月总结的一线大厂Java面试总结,本人已拿大厂offer,欢迎star

原文链接:blog.ouyangsihai.cn >> LNMP架构应用实战——Nginx服务配置文件介绍

LNMP架构应用实战——Nginx服务配置文件介绍

nginx的配置文件比较简单,但功能相当强大,可以自由灵活的进行相关配置,因此,还是了解下其配置文件的一此信息

1、Nginx服务目录结构介绍

安装完成后,在安装路径下就会有Nginx目录信息

[root@centos6 application]# tree nginx

nginx

+– client_body_temp

+– conf         ** #nginx服务配置文件目录**

¦   +– fastcgi.conf             #fastcgi配置文件

¦   +– fastcgi.conf.default

¦   +– fastcgi_params        #fastcgi参数配置文件

¦   +– fastcgi_params.default

¦   +– koi-utf

¦   +– koi-win

¦   +– mime.types

¦   +– mime.types.default

¦   +– nginx.conf                 #nginx服务的主配置文件

¦   +– nginx.conf.default    #nginx服务的默认配置文件

¦   +– scgi_params

¦   +– scgi_params.default

¦   +– uwsgi_params

¦   +– uwsgi_params.default

¦   +– win-utf

+– fastcgi_temp

+– html       #编译安装nginx默认的首页配置文件目录

¦   +– 50x.html           #错误页面配置文件

¦   +– index.html        #默认的首页配置文件

¦   +– index.html.bak

+– logs      #日志配置文件目录

¦   +– access.log      #访问日志文件

¦   +– error.log          #错误日志文件

+– proxy_temp

+– sbin     #命令目录

¦   +– nginx               #Nginx服务启动命令

+– scgi_temp    **#临时目录  **    

+– uwsgi_temp

2、Nginx服务主配置文件介绍

[root@centos6 conf]# egrep -v “#|^$” nginx.conf

worker_processes  1;      #工作进程数

events {                           #事件

    worker_connections  1024;     #并发数,单位时间内最大连接数

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {               #虚拟主机标签

        listen       80;   #监听的端口号

        server_name  localhost;     #服务器主机名

        location / {

            root   html;          #默认站点目录

            index  index.html index.htm;       #默认首页文件

        }

        error_page   500 502 503 504  /50x.html;    #错误页面文件

        location = /50x.html {

            root   html;

        }

    }

}

3、Nginx服务帮助信息

[root@centos6 conf]# /application/nginx/sbin/nginx -h

nginx version: nginx/1.10.1      #版本信息

Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:

  -?,-h         : this help

  -v            : show version and exit    

#显示版本并退出

  -V            : show version and configure options then exit

#显示版本信息与配置后退出

  -t            : test configuration and exit  

#检查配置(检查语法)

  -T            : test configuration, dump it and exit

  -q            : suppress non-error messages during configuration testing

  -s signal     : send signal to a master process: stop, quit, reopen, reload

  -p prefix     : set prefix path (default: /application/nginx-1.10.1/)

  -c filename   : set configuration file (default: conf/nginx.conf)

#指定配置文件,而非使用nginx.conf

  -g directives : set global directives out of configuration file

4、nginx编译参数查看

[root@centos6 conf]# /application/nginx/sbin/nginx -v

nginx version: nginx/1.10.1

[root@centos6 conf]# /application/nginx/sbin/nginx -V

nginx version: nginx/1.10.1

built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 

built with OpenSSL 1.0.1e-fips 11 Feb 2013

TLS SNI support enabled

configure arguments:

–user=nginx

–group=nginx

–prefix=/application/nginx-1.10.1

–with-http_stub_status_module

–with-http_ssl_module

-with-pcre=/download/tools/pcre-8.38

实际生产环境比较实用的查看参数,比如服务非你自己所安装,但又没有相关文档参考,此参数可以提供一些相关的信息

LNMP架构应用实战——Nginx服务配置文件介绍

长按关注公众号——友侃有笑

本人花费半年的时间总结的《Java面试指南》已拿腾讯等大厂offer,已开源在github ,欢迎star!

本文GitHub https://github.com/OUYANGSIHAI/JavaInterview 已收录,这是我花了6个月总结的一线大厂Java面试总结,本人已拿大厂offer,欢迎star

原文链接:blog.ouyangsihai.cn >> LNMP架构应用实战——Nginx服务配置文件介绍


 上一篇
LNMP架构应用实战——Nginx服务介绍与安装 LNMP架构应用实战——Nginx服务介绍与安装
LNMP架构应用实战——Nginx服务介绍与安装          **    应部分小伙伴的需求,今天给各位小伙伴位介绍下关于近几年特别火的nginx服务,同时也是运维屌丝们必须要掌握的WEB服务当中的一种,功能还是比较强大的,因此还
2021-04-05
下一篇 
Linux系统shell脚本编程——生产实战案例 Linux系统shell脚本编程——生产实战案例
Linux系统shell脚本编程——生产实战案例 **     **在日常的生产环境中,可能会遇到需要批量检查内网目前在线的主机IP地址有哪些,还可能需要检查这些在线的主机哪些端口是开放状态,因此依靠手工来检查是可以实现,但比较费时费力
2021-04-05