本文給大家介紹的關(guān)于php + nginx項(xiàng)目權(quán)限的相關(guān)內(nèi)容,分享出來(lái)供大家參考學(xué)習(xí),下面來(lái)看看詳細(xì)的介紹:
nginx/php-fpm
進(jìn)程權(quán)限
1、nginx的用戶為nginx.conf中配置的用戶
2、php-fpm的用戶為php-fpm.conf中配置的用戶
如:?jiǎn)?dòng)nginx的是root,nginx中配置的user是nginx,那主進(jìn)程就是root,子進(jìn)程就是nginx
處理方式
以下訪問(wèn)均以nginx子進(jìn)程進(jìn)行
靜態(tài)文件
步驟:nginx訪問(wèn)/index.html時(shí),nginx會(huì)直接訪問(wèn)對(duì)應(yīng)文件,并將內(nèi)容返回給請(qǐng)求的客戶端。 權(quán)限情況:此時(shí)只需要nginx擁有index.html文件的權(quán)限即可。php腳本文件
步驟:
權(quán)限情況:
用戶配置位置
nginx用戶設(shè)置在nginx.conf中第一行的user
php-fpm用戶設(shè)置在php-fpm.conf中的
listen.owner = xxx;設(shè)置unix socket用戶 user = xxx設(shè)置進(jìn)程啟動(dòng)用戶注:以上兩個(gè)配置文件不同的操作系統(tǒng)下文件名略有不同,請(qǐng)根據(jù)自身安裝情況自行判斷。
nginx轉(zhuǎn)發(fā)內(nèi)容到php-fpm不只有/var/run/php5-fpm.sock的方式,在php-fpm.conf中還可以通過(guò)配置改為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
其他
比較特別的點(diǎn),一般nginx都是用root用戶啟動(dòng)的(為了獲取80端口權(quán)限),如果本地開發(fā)nginx是用普通用戶重啟,那么主進(jìn)程和子進(jìn)程都會(huì)是當(dāng)前用戶,nginx.conf中的配置不再起效,暫不清楚原因。
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)錯(cuò)新站長(zhǎng)站的支持。
新聞熱點(diǎn)
疑難解答
圖片精選