溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

LNMP架構中Nginx服務配置文件的示例分析

發(fā)布時間:2021-12-07 14:54:44 來源:億速云 閱讀:152 作者:小新 欄目:云計算

這篇文章將為大家詳細講解有關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參數(shù)配置文件

|   +-- 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;      #工作進程數(shù)

events {                           #事件

    worker_connections  1024;     #并發(fā)數(shù),單位時間內最大連接數(shù)

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {               #虛擬主機標簽

        listen       80;   #監(jiān)聽的端口號

        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編譯參數(shù)查看

[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

實際生產(chǎn)環(huán)境比較實用的查看參數(shù),比如服務非你自己所安裝,但又沒有相關文檔參考,此參數(shù)可以提供一些相關的信息

關于“LNMP架構中Nginx服務配置文件的示例分析”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI