搜尋
首頁後端開發php教程nginx基本介紹(基於官方文件)

nginx has one master process and several worker processes. The main purpose of the master process is to read and evaluate configuration, and maintain worker processes. Worker processes do actual processing of requests. nginxemploys eventer mechanisms to efficiently distribute requests among worker processes. The number of worker processes is defined in the configuration file and may be fixed for a given configuration or automatically.

The way nginx and its modules work is determined in the configuration file. By default, the configuration file is named nginx.conf and placed in the directory /usr/local/nginx/conf, /etc/nginx, local. /etc/nginx.

nginx由一個master進程和若干worker進程組成,master進程主要用於讀取設定檔和管理worker進程.worker進程負責處理請求。 nginx基於事件模型並且能夠根據作業系統的特性高效的利用worker進程處理請求。 worker進程的數量在設定檔中定義,也可以透過指定的設定檔來定義其數量,或自動根據CPU核心數來確定其數量。
nginx以及相關模組的工作方式是透過設定檔來指定。預設情況下,設定檔命名為nginx.conf,位於/usr/local/nginx/conf 或 /etc/nginx 或 /usr/local/etc/nginx 路徑下。

以下內容為nginx啟動,關the executable with the 

-s
 parameter. Use the following syntax:

nginx -s <em>signal</em>

Where signal may be 38 the folloWhere 

signal
 
quit

 — graceful shutdown

reload
     — reloading the configuration file
  • reopen
  •  — reopening the log files
  • For example, to stop nginx process with procesd ed:
  • nginx -s quit
    
    This command should be executed under the same user that started nginx.
  • Changes made in the configuration file will not be applied until the command to reload configuration file will not be applied until the command to reload configuration isload p膜 <pre class="brush:php;toolbar:false">nginx -s reload </pre>
  • Once the master process receives the signal to reload configuration, it checks the syntax validity of the new configuration file and tries to apply the configuration provided in it. If this is 5, the apply the configuration provided in it. If this is messages to old worker processes, requesting them to shut down. Otherwise, the master process rolls back the changes and continues to work with the old configuration. Old worker processes, receiving a command to shut down, stop cepting new. continue to service current requests until all such requests are serviced. After that, the old worker processes exit.

一旦啟動了nginx,就可以透過其中nginx -s [signal]命令的方式來控制其中包括signalinx.可以以下的指令:

stop
 — 快速停止

quit

  — 重新開啟日誌檔案

例如,等待worker進程處理完目前請求後再關閉nginx,可以使用

  • nginx -s quit
  • 當配置文件被更改,只有當nginx被重啟或接收到重載配置文件的命令時新的配置文件才會生效,為了更改配置文件後生效,可以使用



nginx -s reload

一旦master程序接收到重載配置文件的信號,它首先會檢查新的配置文件是否有語法錯誤,如果沒有錯誤,master進程將會採用新的配置,並啟動新的worker進程,同時通知舊的worker進程讓他們停止工作。否則,若設定檔存在錯誤,那麼master進程仍然使用舊的配置,並且舊的worker進程將繼續保持工作。一旦master進程通知worker進程停止工作,worker進程首先會停止接收鏈接,然後處理完當前的所有請求,之後再exit,結束執行。 🎜🎜🎜 🎜 以上就介紹了nginx基本介紹(基於官方文件),包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。 🎜 🎜 🎜
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
可以在PHP會話中存儲哪些數據?可以在PHP會話中存儲哪些數據?May 02, 2025 am 12:17 AM

phpsessionscanStorestrings,數字,數組和原始物。

您如何開始PHP會話?您如何開始PHP會話?May 02, 2025 am 12:16 AM

tostartaphpsession,usesesses_start()attheScript'Sbeginning.1)placeitbeforeanyOutputtosetThesessionCookie.2)useSessionsforuserDatalikeloginstatusorshoppingcarts.3)regenerateSessiveIdStopreventFentfixationAttacks.s.4)考慮使用AttActAcks.s.s.4)

什麼是會話再生,如何提高安全性?什麼是會話再生,如何提高安全性?May 02, 2025 am 12:15 AM

會話再生是指在用戶進行敏感操作時生成新會話ID並使舊ID失效,以防會話固定攻擊。實現步驟包括:1.檢測敏感操作,2.生成新會話ID,3.銷毀舊會話ID,4.更新用戶端會話信息。

使用PHP會話時有哪些性能考慮?使用PHP會話時有哪些性能考慮?May 02, 2025 am 12:11 AM

PHP会话对应用性能有显著影响。优化方法包括:1.使用数据库存储会话数据,提升响应速度;2.减少会话数据使用,只存储必要信息;3.采用非阻塞会话处理器,提高并发能力;4.调整会话过期时间,平衡用户体验和服务器负担;5.使用持久会话,减少数据读写次数。

PHP會話與Cookie有何不同?PHP會話與Cookie有何不同?May 02, 2025 am 12:03 AM

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

PHP如何識別用戶的會話?PHP如何識別用戶的會話?May 01, 2025 am 12:23 AM

phpIdentifiesauser'ssessionSessionSessionCookiesAndSessionId.1)whiwsession_start()被稱為,phpgeneratesainiquesesesessionIdStoredInacookInAcookInAcienamedInAcienamedphpsessIdontheuser'sbrowser'sbrowser.2)thisIdallowSphptpptpptpptpptpptpptpptoretoreteretrieetrieetrieetrieetrieetrieetreetrieetrieetrieetrieetremthafromtheserver。

確保PHP會議的一些最佳實踐是什麼?確保PHP會議的一些最佳實踐是什麼?May 01, 2025 am 12:22 AM

PHP會話的安全可以通過以下措施實現:1.使用session_regenerate_id()在用戶登錄或重要操作時重新生成會話ID。 2.通過HTTPS協議加密傳輸會話ID。 3.使用session_save_path()指定安全目錄存儲會話數據,並正確設置權限。

PHP會話文件默認存儲在哪裡?PHP會話文件默認存儲在哪裡?May 01, 2025 am 12:15 AM

phpsessionFilesArestoredIntheDirectorySpecifiedBysession.save_path,通常是/tmponunix-likesystemsorc:\ windows \ windows \ temponwindows.tocustomizethis:tocustomizEthis:1)useession_save_save_save_path_path()

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。