欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

nginx啟動命令和默認配置文件的使用

 更新時間:2025年06月16日 14:07:51   作者:Gen鄧艮艮  
這篇文章主要介紹了nginx啟動命令和默認配置文件的使用,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

常見命令

# 默認配置文件啟動
./nginx
# 停止
./nginx -s stop
# 重啟,加載默認配置文件  
./nginx -s reload
# 啟動指定某個配置文件
./nginx -c /usr/local/nginx/conf/nginx.conf

nginx.conf配置文件

#user  nobody;					# 指定Nginx worker進程運行以及用戶組
worker_processes  1;

#error_log  logs/error.log;		# 錯誤日志的存放路徑
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;		# 進程pid存放路徑

# 事件模塊指令,用來指定Nginx的IO模型,Nginx支持的有select、poll、kqueue、epoll等。不同的是epoll用在Linux平臺上,而kqueue用在BSD系統(tǒng)中,對于Linux系統(tǒng),epoll工作模式是首選
events {
	use epoll;
	# 定義Nginx每個進程的最大連接數(shù),作為服務器來說:worker_connections * worker_processes;作為反向代理來說,最大并發(fā)數(shù)量為:worker_connections * worker_processes / 2,因為反向代理服務器,每個并發(fā)會建立與客戶端的連接和與后端服務的連接,會占用兩個連接
    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;

	# 是否開啟高效傳輸模式 on開啟 off關閉
    sendfile        on;
    # 減少網(wǎng)絡報文段的數(shù)量
    #tcp_nopush     on;
	
	# 客戶端連接超時時間
    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
	
	# 虛擬主機的配置
    server {
        listen       80;		# 虛擬主機的服務端口
        server_name  localhost;	# 用來指定IP地址或域名,多個域名之間用空格分開

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

		# URL地址匹配
        location / {
            root   html;					# 服務默認啟動目錄
            index  index.html index.htm;	# 默認訪問文件,按照順序找
        }

        #error_page  404              /404.html;	# 錯誤狀態(tài)碼的顯示頁面

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

}

location匹配規(guī)則

正則

  • ^:開始符號
  • $:結束符號

location路徑匹配

  • location = /uri:=表示精準匹配,只有完全匹配上才能生效
  • location /uri:不帶任何修飾符,表示前綴匹配
  • location ^~ /uri:匹配任何以/uri開頭的匹配到就停止搜索
  • location /:通用匹配

正則匹配

  • 區(qū)分大小寫匹配:~
  • 不區(qū)分大小寫匹配:~*

圖片服務器

server {
    listen       80;
    server_name  localhost a.com;

    location / {
        root   html;
        index  index.html index.htm;
    }
    location /img {
        alias /usr/local/img/;
    }
}

注意

  • 在location / 中配置root目錄
  • 在location /path 中配置alias虛擬目錄,目錄后面的"/"符號一定要帶上

總結

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

  • Nginx+SSL實現(xiàn)雙向認證的示例代碼

    Nginx+SSL實現(xiàn)雙向認證的示例代碼

    這篇文章主要介紹了Nginx+SSL實現(xiàn)雙向認證的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • Nginx 安裝筆記(含PHP支持、虛擬主機、反向代理負載均衡)

    Nginx 安裝筆記(含PHP支持、虛擬主機、反向代理負載均衡)

    Nginx安裝簡記(含PHP支持、虛擬主機、反向代理負載均衡) Nginx,據(jù)說高性能和穩(wěn)定性比Apache還牛,并發(fā)連接處理能力強,低系統(tǒng)資源消耗。目前已有250多萬web站點在使用
    2009-10-10
  • Nginx配置入門教程

    Nginx配置入門教程

    這篇文章主要介紹了Nginx配置入門教程,本文講解了反向代理的概念、初始配置、進階配置、負載均衡配置等內(nèi)容,需要的朋友可以參考下
    2015-02-02
  • Nginx?請求超時的實現(xiàn)

    Nginx?請求超時的實現(xiàn)

    Nginx請求超時是服務器無法在規(guī)定時間內(nèi)完成對客戶端請求的響應,本文就來介紹一下Nginx?請求超時的實現(xiàn),具有一定的參考價值,感興趣的可以了解一下
    2025-02-02
  • Nginx Proxy緩存的具體實現(xiàn)

    Nginx Proxy緩存的具體實現(xiàn)

    本文主要介紹了Nginx Proxy緩存的具體實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-08-08
  • windows查看nginx是否啟動及常用命令小結

    windows查看nginx是否啟動及常用命令小結

    這篇文章主要給大家介紹了關于windows查看nginx是否啟動及常用命令的相關資料,在Windows系統(tǒng)中,可以使用以下命令來操作和管理Nginx,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2024-06-06
  • Nginx session丟失問題處理解決方法

    Nginx session丟失問題處理解決方法

    這篇文章主要介紹了Nginx session丟失問題處理解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-04-04
  • 定期刪除OpenResty/Nginx大日志文件的方法

    定期刪除OpenResty/Nginx大日志文件的方法

    這篇文章主要介紹了定期刪除OpenResty/Nginx大日志文件的方法,文中通過代碼示例給大家講解的非常詳細,對大家的學習或工作有一定的幫助,需要的朋友可以參考下
    2024-05-05
  • 淺談一下Nginx性能優(yōu)化

    淺談一下Nginx性能優(yōu)化

    這篇文章主要介紹了Nginx性能優(yōu)化,Nginx (engine x) 是一個高性能的HTTP和反向代理web服務器,同時也提供了IMAP/POP3/SMTP服務,需要的朋友可以參考下
    2023-04-04
  • 網(wǎng)頁502?Bad?Gateway?nginx/1.20.1報錯的原因與解決方法

    網(wǎng)頁502?Bad?Gateway?nginx/1.20.1報錯的原因與解決方法

    502 bad gateway nginx/1.20.1 是一個錯誤提示,通常出現(xiàn)在訪問網(wǎng)站時出現(xiàn)問題,這篇文章主要給大家介紹了關于網(wǎng)頁502?Bad?Gateway?nginx/1.20.1報錯的原因與解決方法,需要的朋友可以參考下
    2024-03-03

最新評論