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

php + nginx項目中的權(quán)限詳解

 更新時間:2017年05月23日 10:26:56   作者:呂劉杰  
這篇文章主要給大家介紹了關于php + nginx項目中權(quán)限的相關資料,文章介紹的非常詳細,對大家具有一定的參考學習價值,需要的朋友們下面來一起看看吧。

本文給大家介紹的關于php + nginx項目權(quán)限的相關內(nèi)容,分享出來供大家參考學習,下面來看看詳細的介紹:

nginx/php-fpm

進程權(quán)限

  • 主進程用戶為啟動的用戶
  • 子進程

1、nginx的用戶為nginx.conf中配置的用戶

2、php-fpm的用戶為php-fpm.conf中配置的用戶

如:啟動nginx的是root,nginx中配置的user是nginx,那主進程就是root,子進程就是nginx

處理方式

以下訪問均以nginx子進程進行

靜態(tài)文件

  • 步驟:nginx訪問/index.html時,nginx會直接訪問對應文件,并將內(nèi)容返回給請求的客戶端。
  • 權(quán)限情況:此時只需要nginx擁有index.html文件的權(quán)限即可。

php腳本文件

步驟:

  • nginx訪問/index.php時,nginx為了能夠把正確的腳本處理結(jié)果返回給客戶端,需要進行配置告訴nginx.php是非靜態(tài)文件,需要php腳本解析器進行處理后才能返回內(nèi)容。
  • 一般來講會在nginx配置中加上類似fastcgi_pass unix:/var/run/php5-fpm.sock;這樣的配置項,指明nginx在遇到訪問腳本文件時需要去找誰,之后會訪問該文件做到將請求轉(zhuǎn)發(fā)至php-fpm。
  • 由php-fpm訪問真正的php腳本文件,將結(jié)果返回值nginx,再有nginx將結(jié)果返回至客戶端。

權(quán)限情況:

  • nginx需要有/var/run/php5-fpm.sock文件權(quán)限;
  • php-fpm需要有/index.php文件權(quán)限;

用戶配置位置

nginx用戶設置在nginx.conf中第一行的user

php-fpm用戶設置在php-fpm.conf中的

  • listen.owner = xxx;設置unix socket用戶
  • user = xxx設置進程啟動用戶

注:以上兩個配置文件不同的操作系統(tǒng)下文件名略有不同,請根據(jù)自身安裝情況自行判斷。

nginx轉(zhuǎn)發(fā)內(nèi)容到php-fpm不只有/var/run/php5-fpm.sock的方式,在php-fpm.conf中還可以通過配置改為xxx.xxx.xxx:9000等方式

; 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端口權(quán)限),如果本地開發(fā)nginx是用普通用戶重啟,那么主進程和子進程都會是當前用戶,nginx.conf中的配置不再起效,暫不清楚原因。

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關文章

最新評論