Nginx與PHP的兩種通訊方式-unix socket和tcp socket
##兩者Nginx設定 (推薦學習:nginx教學)
unix socket
需要在nginx設定檔中填寫php-fpm運行的pid檔案位址。location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; }
tcp socket
需要在nginx設定檔中填入php-fpm運行的ip位址和連接埠號碼。location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; }
兩者比較
以上是php與nginx如何通信的詳細內容。更多資訊請關注PHP中文網其他相關文章!