Home >php教程 >PHP源码 >php-fpm设置socket方式连接FastCGI

php-fpm设置socket方式连接FastCGI

WBOY
WBOYOriginal
2016-06-08 17:20:091614browse

本文章来为各位介绍一篇关于php-fpm设置socket方式连接FastCGI的例子,希望文章可能帮助到各位深入的理解socket方式连接FastCGI的知识。

<script>ec(2);</script>

socket方式不会走到tcp层,tcp方式则会走到ip层。因此,理论上说socket连接方式效率会更好一点。
TCP和unix domain socket方式对比

 

TCP是使用TCP端口连接127.0.0.1:9000

Socket是使用unix domain socket连接套接字/dev/shm/php-fpm.sock

修改php-fpm.conf配置

#listen = 127.0.0.1:9000 

 

listen=/dev/shm/php-fpm.sock #/dev/shm/为内存文件系统,注意 确保可读写

listen.owner=apache  #注意自己的用户和组

listen.group=apache

 修改nginx.conf配置

#fastcgi_pass    127.0.0.1:9000;
#将相应的如上内容修改如下
fastcgi_pass     unix:/dev/shm/php-fpm.sock;

重启nginx和php-fpm

service nginx restart

/usr/local/nginx/sbin/nginx -s reload

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn