這篇文章主要為大家介紹了關於php + nginx專案中權限的相關資料,文章介紹的非常詳細,對大家具有一定的參考學習價值,需要的朋友們下面來一起看看吧。
本文介紹給大家的關於php + nginx專案權限的相關內容,分享出來供大家參考學習,以下來看看詳細的介紹:
nginx/ php-fpm
程式權限
#主程式使用者為啟動的使用者
子程序
1、nginx的使用者為nginx.conf中配置的使用者
2、php- fpm的使用者為php-fpm.conf中配置的使用者
如:啟動nginx的是root,nginx中配置的user是nginx,那主行程就是root,子行程就是nginx
處理方式
以下存取皆以nginx子程序進行
靜態檔案
步驟:nginx存取/index.html時,nginx會直接存取對應文件,並將內容傳回給請求的用戶端。
權限狀況:此時只需nginx擁有index.html檔案的權限即可。
php腳本檔案
步驟:
nginx存取/ index.php時,nginx為了能夠把正確的腳本處理結果回傳給客戶端,需要進行設定告訴nginx.php是非靜態文件,需要php腳本解析器進行處理後才能回傳內容。
一般來講會在nginx配置中加上類似fastcgi_pass unix:/var/run/php5-fpm.sock;這樣的設定項,指明nginx在遇到存取腳本文件時需要去找誰,之後會存取該檔案做到將請求轉送至php-fpm。
由php-fpm存取真正的php腳本文件,將結果傳回值nginx,再有nginx將結果傳回客戶端。
權限狀況:
#nginx需要有/var/run/php5-fpm.sock檔案權限;
php-fpm需要有/index.php檔案權限;
使用者配置位置
nginx使用者設定在nginx.conf中第一行的user
php-fpm使用者設定在php-fpm.conf中的
listen.owner = xxx;設定unix socket用戶
user = xxx設定程序啟動使用者
; The address on which to accept FastCGI requests. ; Valid syntaxes are: ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on ; a specific port; ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on ; a specific port; ; 'port' - to listen on a TCP socket to all IPv4 addresses on a ; specific port; ; '[::]:port' - to listen on a TCP socket to all addresses ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. listen = /var/run/php5-fpm.sock######其他#############比較特別的點,一般nginx都是用root使用者啟動的(為了取得80連接埠權限),如果本地開發nginx是用普通用戶重啟,那麼主進程和子進程都會是當前用戶,nginx.conf中的配置不再起效,暫不清楚原因。 ###
以上是詳解php + nginx的權限的詳細內容。更多資訊請關注PHP中文網其他相關文章!

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

使用依賴注入(DI)的原因是它促進了代碼的松耦合、可測試性和可維護性。 1)使用構造函數注入依賴,2)避免使用服務定位器,3)利用依賴注入容器管理依賴,4)通過注入依賴提高測試性,5)避免過度注入依賴,6)考慮DI對性能的影響。

phpperformancetuningiscialbecapeitenhancesspeedandeffice,whatevitalforwebapplications.1)cachingwithapcureduccureducesdatabaseloadprovesrovessetimes.2)優化

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

TOOPTIMIZEPHPAPPLICITIONSFORPERSTORANCE,USECACHING,數據庫imization,opcodecaching和SererverConfiguration.1)InlumentCachingWithApcutCutoredSatfetchTimes.2)優化的atabasesbasesebasesebasesbasesbasesbaysbysbyIndexing,BeallancingAndWriteExing

依賴性注射inphpisadesignpatternthatenhancesFlexibility,可檢驗性和ManiaginabilybyByByByByByExternalDependencEctenceScoupling.itallowsforloosecoupling,EasiererTestingThroughMocking,andModularDesign,andModularDesign,butquirscarecarefulscarefullsstructoringDovairing voavoidOverOver-Inje

PHP性能優化可以通過以下步驟實現:1)在腳本頂部使用require_once或include_once減少文件加載次數;2)使用預處理語句和批處理減少數據庫查詢次數;3)配置OPcache進行opcode緩存;4)啟用並配置PHP-FPM優化進程管理;5)使用CDN分發靜態資源;6)使用Xdebug或Blackfire進行代碼性能分析;7)選擇高效的數據結構如數組;8)編寫模塊化代碼以優化執行。

opcodecachingsimplovesphperforvesphpermance bycachingCompiledCode,reducingServerLoadAndResponSetimes.1)itstorescompiledphpcodeinmemory,bypassingparsingparsingparsingandcompiling.2)useopcachebachebachebachebachebachebachebysettingparametersinphametersinphp.ini,likeememeryconmorysmorysmeryplement.33)


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

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

熱門文章

熱工具

Dreamweaver CS6
視覺化網頁開發工具

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

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

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。