關(guān)于nginx&php-fpm,應該是按照cgi協(xié)議規(guī)范“通訊”,nginx與php-cli是怎么實現(xiàn)的?(stream?)
實現(xiàn)方式上有什么區(qū)別,需要注意哪些地方?($_GET $_POST之外)
nginx 和 php-fpm 通訊靠fastcgi協(xié)議的兩種方式
location ~ [^/]\.php(/|$) {
fastcgi_pass 通訊方式;
fastcgi_index index.php;
include fastcgi.conf;
}
通訊方式
#tcp socket
fastcgi_pass 127.0.0.1:9000;
#unix socket
fastcgi_pass unix:/dev/shm/php-cgi.sock;
nginx和php-cil下的http服務(webman,hyperf)不需要通訊,一般用nginx是需要為接口或網(wǎng)頁綁定域名和證書,隱藏服務器真實ip,做反向代理服務器。
server {
listen 80;
server_name proxy (代理) .stu;
...
location / {
...
#后端http服務地址,可以是任何后端語言寫的http服務
proxy_pass http://127.0.0.1:8080;
}
}
反向代理,可以理解為保持原來的請求狀態(tài)(http協(xié)議),php-cli(如webman)按照http協(xié)議解析獲取請求參數(shù)?