mysql socket php fpm_配置 php-fpm 监听的socket

一般现在我们配置的PHP的web环境,如LNMP(linux+Nginx+Mysql+PHP), 这里linux可能是centos, ubuntu..., 数据库可能是mysql, postgresql, sql server等。。在服务器上安装PHP-FPM, nginx后, 我们要配置Nginx的http模块, 让 .php的文件由nginx 转发给PHP-FPM处理,然后在将php-fpm的...
摘要由CSDN通过智能技术生成

一般现在我们配置的PHP的web环境,如LNMP(linux+Nginx+Mysql+PHP), 这里linux可能是centos, ubuntu..., 数据库可能是mysql, postgresql, sql server等。。

在服务器上安装PHP-FPM, nginx后, 我们要配置Nginx的http模块, 让 .php的文件由nginx 转发给PHP-FPM处理,然后在将php-fpm的处理结果通过http响应传给浏览器,就完成了一次http的请求。。

在配置 Nginx 的http模块的时候, 通常是这样:

server ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass 127.0.0.1:9000;

}

也可以这样,

server ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/var/run/php5-fpm.sock;

}

那么这两种方式有什么区别呢??

这就是我这篇博文所要解释的问题。下面,我带大家来分析一下其中的原理,一下是我的一些理解,不对的地方还请大家不吝赐教,我将很感激~~

PHP-FPM can listen on multiple sockets. I also listen on Unix sockets, or TCP sockets. See how this works and how to ensure Nginx is properly sending requests to PHP-FPM.

Command Rundown

Default Configuration

Edit PHP-FPM configuration

# Configure PHP-FPM default resource pool

sudo vim /etc/php5/fpm/pool.d/www.conf

PHP-FPM Listen configuration:

# Stuff omitted

listen = /var/run/php5-fpm.sock

listen.owner = www-data

listen.group = www-data

Also edit Nginx and see where it's sending request to PHP-FPM:

# Files: /etc/nginx/sites-available/default

# ... stuff omitted

server ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/var/run/php5-fpm.sock;

}

We can see above that Nginx is sending requests to PHP-FPM via a unix socket (faux file) at /var/run/php5-fpm.sock. This i

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值