Nginx+PHP-FPM的域Socket配置方法
2013-07-15 21:01
537 查看
1什么是域Socket
“Unix domain socket 或者 IPCsocket 是一种终端,可以使同一台操作系统上的两个或多个进程进行数据通信。与管道相比,Unix domain sockets 既可以使用字节流数和数据队列,而管道通信则只能通过字节流。Unix domain sockets的接口和Internet socket很像,但它不使用网络底层协议来通信。Unix domain socket 的功能是POSIX操作系统里的一种组件。 Unixdomain sockets 使用系统文件的地址来作为自己的身份。它可以被系统进程引用。所以两个进程可以同时打开一个Unix domain sockets来进行通信。不过这种通信方式是发生在系统内核里而不会在网络里传播。”
-----维基百科
2创建Socket文件
在/dev/shm下,执行:touch php-fcgi.sock
chown admin:admin php-fcgi.sock
chmod 777 php-fcgi.sock
3 Nginx配置
===============================================================================server
{
listen 80;
server_name cdai.net;
autoindex off;
error_page403 /index.php;
error_page404 /index.php;
if( $fastcgi_script_name ~ \..*\/.*php ) {
return403;
}
location / {
index index.php;
root /home/cdai;
}
location ~ \.php$ {
root /home/cdai;
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME/cdai.net$fastcgi_script_name;
}
}
4 PHP-FPM配置
/etc/php-fpm.d/www.conf配置改动如下:===============================================================================
listen= /tmp/php-fcgi.sock
listen.owner= admin
listen.group =admin
5重启服务
重启Nginx服务:nginx-s reload
重启PHP-FPM
注意:一定要完全停掉再启动,不能用USR2信号平滑重启。
这时再看Socket文件就会看到文件类型变成了s,通信已建立。
相关文章推荐
- Nginx+PHP-FPM的域Socket配置方法
- Nginx+PHP-FPM的域Socket配置方法
- nginx+php-fpm配置后页面显示空白的解决方法
- nginx+php-fpm配置后页面显示空白的解决方法
- nginx+php-fpm配置后页面显示空白的解决方法
- nginx+php-fpm的socket配置小结
- (开包即用,不用看代码!)Windows下NetBeans调试Docker中nginx+PHP-fpm路由的八种配置以及两种控制台配置两种DotNet配置
- nginx+php(php-fpm)+mysql配置
- 安装配置php-fpm来搭建Nginx+PHP的生产环境
- nginx+php-fpm配置文件的组织结构介绍
- nginx、php-fpm默认配置与性能–TCP socket还是unix domain socket
- nginx+php-fpm出现502 bad gateway错误解决方法
- 配置 php-fpm 监听的socket
- nginx+php-fpm相关配置
- nginx+php-fpm+mysql配置后需要作的事
- nginx php-fpm unixsocket并发100以上报502解决方法
- Centos配置完php-fpm和Nginx之后,只能打开php无法加载其他文件处理方法
- nginx调用php-fpm出错解决方法和nginx配置详解
- nginx+php-fpm出现502 bad gateway错误解决方法