本文給大家介紹的關于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用戶設置在nginx.conf中第一行的user
php-fpm用戶設置在php-fpm.conf中的
listen.owner = xxx;設置unix socket用戶 user = xxx設置進程啟動用戶注:以上兩個配置文件不同的操作系統下文件名略有不同,請根據自身安裝情況自行判斷。
nginx轉發內容到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端口權限),如果本地開發nginx是用普通用戶重啟,那么主進程和子進程都會是當前用戶,nginx.conf中的配置不再起效,暫不清楚原因。
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對錯新站長站的支持。
新聞熱點
疑難解答