安然小屋 安然之家

安然小屋 安然之家

nginx 中 fastcgi_pass设置为监听unix socket 比监听tcp socket 执行效率高
2016-12-29

官方有如下说明:

; 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 address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.listen = 127.0.0.1:9000


astcgi_pass  unix:/tmp/php-cgi.sock  这是放在磁盘
fastcgi_pass  127.0.0.1:9000

unix socket会更加快一点,不走网络  另外放在/tmp目录不如放在内存里面   我一般放在 /dev/shm/php-fpm.sock   放在内存读取速度快更快的

查看效果:

ls -al /dev/shm