zoukankan      html  css  js  c++  java
  • Nginx与PHP的交互

    转载自

    Nginx与PHP的两种通信方式-unix socket和tcp socket

    unix socket

    需要在nginx配置文件中填写php-fpm运行的pid文件地址。(按自己路径来定)

            []()location ~ .php$ {
            include fastcgi_params;
            fastcgi_pass unix:/tmp/php-fcgi.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; }
    

    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; }
    

    优劣

    unix socket减少了不必要的tcp开销,而tcp需要经过loopback,还要申请临时端口和tcp相关资源。但是,unix socket高并发时候不稳定,连接数爆发时,会产生大量的长时缓存,在没有面向连接协议的支撑下,大数据包可能会直接出错不返回异常。tcp这样的面向连接的协议,多少可以保证通信的正确性和完整性。

  • 相关阅读:
    inner join on, left join on, right join on讲解(转载)
    ref 与 out
    Shell基础01
    Python 基础01
    linux基础03
    Shell基础02
    linux基础02
    Linux基础01
    linux基础05
    linux基础04
  • 原文地址:https://www.cnblogs.com/hxlinux/p/12906942.html
Copyright © 2011-2022 走看看