Linux 如何找到我的 php-fpm.sock?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17570658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find my php-fpm.sock?
提问by Márcio
I'm running Wordpress with: Nginx + PHP-FPM + APC + W3 Total Cache + PageSpeed.
我正在运行 Wordpress:Nginx + PHP-FPM + APC + W3 Total Cache + PageSpeed。
After 3 days researching and configuring, I succeeded to make it work. I configured PHP-FPM to run via 127.0.0.1:9000. But now I want to configure via Socket.
经过3天的研究和配置,我成功地使它工作。我将 PHP-FPM 配置为通过 127.0.0.1:9000 运行。但现在我想通过 Socket 进行配置。
The problem is that I can't find the socket path in my server. I just found /var/run/php-fpm/php-fpm.pid
, but php-fpm.sock
was not there.
问题是我在我的服务器中找不到套接字路径。我刚找到/var/run/php-fpm/php-fpm.pid
,但php-fpm.sock
不在那里。
Running whereis php-fpm
the output is:
运行whereis php-fpm
输出是:
php-fpm: /usr/sbin/php-fpm /etc/php-fpm.d /etc/php-fpm.conf /usr/share/man/man8/php-fpm.8.gz
But there isn't any php-fpm.sock
there.
但那里没有php-fpm.sock
。
How can I find php-fpm.sock
?
我怎样才能找到php-fpm.sock
?
My specs:
我的规格:
- Amazon Micro EC2
- Linux version 3.4.48-45.46.amzn1.x86_64 Red Hat 4.6.3-2 (I think it's based on CentOS 5)
- PHP 5.3.26 (fpm-fcgi)
- 亚马逊微型 EC2
- Linux 版本 3.4.48-45.46.amzn1.x86_64 Red Hat 4.6.3-2(我认为它基于 CentOS 5)
- PHP 5.3.26 (fpm-fcgi)
回答by Mohammad AbuShady
Check the config file, the config path is /etc/php5/fpm/pool.d/www.conf
, there you'll find the path by config and if you want you can change it.
检查配置文件,配置路径是/etc/php5/fpm/pool.d/www.conf
,在那里您可以通过配置找到路径,如果您愿意,可以更改它。
EDIT:
well you're correct, you need to replace listen = 127.0.0.1:9000
to listen = /var/run/php5-fpm/php5-fpm.sock
, then you need to run sudo service php5-fpm restart
, and make sure it says that it restarted correctly, if not then make sure that /var/run/
has a folder called php5-fpm
, or make it listen to /var/run/php5-fpm.sock
cause i don't think the folder inside /var/run
is created automatically, i remember i had to edit the start up script to create that folder, otherwise even if you mkdir /var/run/php5-fpm
after restart that folder will disappear and the service starting will fail.
编辑:
嗯,你是对的,你需要替换listen = 127.0.0.1:9000
为listen = /var/run/php5-fpm/php5-fpm.sock
,然后你需要运行sudo service php5-fpm restart
,并确保它说它正确重新启动,如果没有,那么确保/var/run/
有一个名为 的文件夹php5-fpm
,或者让它听,/var/run/php5-fpm.sock
因为我不不认为里面的文件夹/var/run
是自动创建的,我记得我必须编辑启动脚本才能创建该文件夹,否则即使您mkdir /var/run/php5-fpm
重新启动该文件夹后该文件夹也会消失并且服务启动将失败。
回答by Fath
I know this is old questions but since I too have the same problem just now and found out the answer, thought I might share it. The problem was due to configuration at pood.d/ directory.
我知道这是老问题,但因为我刚才也有同样的问题并找到了答案,所以我想我可以分享一下。问题是由于 pood.d/ 目录中的配置造成的。
Open
打开
/etc/php5/fpm/pool.d/www.conf
find
找
listen = 127.0.0.1:9000
change to
改成
listen = /var/run/php5-fpm.sock
Restart both nginx and php5-fpm service afterwards and check if php5-fpm.sock already created.
之后重启 nginx 和 php5-fpm 服务并检查 php5-fpm.sock 是否已经创建。
回答by specialk1st
I faced this same issue on CentOS 7 years later
7 年后,我在 CentOS 上遇到了同样的问题
Posting hoping that it may help others...
发帖希望能帮到其他人...
Steps:
脚步:
FIRST, configure the php-fpm settings:
首先,配置 php-fpm 设置:
-> systemctl stop php-fpm.service
-> systemctl stop php-fpm.service
-> cd /etc/php-fpm.d
-> cd /etc/php-fpm.d
-> ls -hal
(should see a www.conf file)
-> ls -hal
(应该会看到一个 www.conf 文件)
-> cp www.conf www.conf.backup
(back file up just in case)
-> cp www.conf www.conf.backup
(备份文件以防万一)
-> vi www.conf
-> vi www.conf
-> :/listen =
(to get to the line we need to change)
-> :/listen =
(为了到达我们需要更改的行)
-> i
(to enter VI's text insertion mode)
-> i
(进入VI的文本插入模式)
-> change from listen = 127.0.0.1:9000
TO listen = /var/run/php-fpm/php-fpm.sock
-> 从listen = 127.0.0.1:9000
TO更改listen = /var/run/php-fpm/php-fpm.sock
-> Esc
then :/listen.owner
(to find it) then i
(to change)
->Esc
然后:/listen.owner
(找到它)然后i
(改变)
-> UNCOMMENT the listen.owner = nobody
AND listen.group = nobody
lines
-> 取消注释listen.owner = nobody
ANDlisten.group = nobody
行
-> Hit Esc
then type :/user =
then i
- >按Esc
然后键入:/user =
然后i
-> change user = apache
TO user = nginx
- >改变user = apache
TOuser = nginx
-> AND change group = apache
TO group = nginx
- >并更改group = apache
TOgroup = nginx
-> Hit Esc
then :wq
(to save and quit)
->Esc
然后点击:wq
(保存并退出)
-> systemctl start php-fpm.service
(now you will have a php-fpm.sock file)
-> systemctl start php-fpm.service
(现在你会有一个 php-fpm.sock 文件)
SECOND, you configure your server {}
block in your /etc/nginx/nginx.conf
file. Then run:systemctl restart nginx.service
第二,您server {}
在/etc/nginx/nginx.conf
文件中配置块。然后运行:systemctl restart nginx.service
FINALLY, create a new .php file in your /usr/share/nginx/html directory for your Nginx server to serve up via the internet browser as a test.
最后,在您的 /usr/share/nginx/html 目录中为您的 Nginx 服务器创建一个新的 .php 文件,以通过互联网浏览器作为测试提供服务。
-> vi /usr/share/nginx/html/mytest.php
-> vi /usr/share/nginx/html/mytest.php
-> type o
-> 类型 o
-> <?php echo date("Y/m/d-l"); ?>
(PHP page will print date and day in browser)
-> <?php echo date("Y/m/d-l"); ?>
(PHP 页面将在浏览器中打印日期和日期)
-> Hit Esc
-> 命中 Esc
-> type :wq
(to save and quite VI editor)
-> 类型:wq
(保存和相当的 VI 编辑器)
-> open up a browser and go to: http://yourDomainOrIPAddress/mytest.php
(you should see the date and day printed)
-> 打开浏览器并转到:(http://yourDomainOrIPAddress/mytest.php
您应该看到打印的日期和日期)
回答by kaiser
When you look up your php-fpm.conf
当你抬头看你的 php-fpm.conf
example location:
cat /usr/src/php/sapi/fpm/php-fpm.conf
you will see, that you need to configure the PHP FastCGI Process Manager to actually use Unix sockets. Per default, the listen
directive` is set up to listen on a TCP socket on one port. If there's no Unix socket defined, you won't find a Unix socket file.
您将看到,您需要配置 PHP FastCGI 进程管理器才能实际使用 Unix 套接字。默认情况下,该listen
指令设置为侦听一个端口上的 TCP 套接字。如果没有定义 Unix 套接字,您将找不到 Unix 套接字文件。
; 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 IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all IPv4 addresses on a
; specific port;
; '[::]:port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) 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
回答by Kris Roofe
I encounter this issue when I first run LEMP on centos7 refer to this post.
我第一次在 centos7 上运行 LEMP 时遇到了这个问题,请参考这篇文章。
I restart nginx to test the phpinfo page, but get this
我重新启动 nginx 来测试 phpinfo 页面,但是得到这个
http://xxx.xxx.xxx.xxx/info.phpis not unreachable now.
http://xxx.xxx.xxx.xxx/info.php现在不是无法访问。
Then I use tail -f /var/log/nginx/error.log
to see more info. I find is the
php-fpm.sock file not exist. Then I reboot the system, everything is OK.
然后我tail -f /var/log/nginx/error.log
用来查看更多信息。我发现 php-fpm.sock 文件不存在。然后我重新启动系统,一切正常。
Here may not need to reboot the system as Fath's post, just reload nginx and php-fpm.
这里可能不需要像Fath的帖子那样重启系统,只需重新加载nginx和php-fpm即可。
回答by Mdev
Solved in my case, i look at
在我的情况下解决了,我看看
sudo tail -f /var/log/nginx/error.log
and error is php5-fpm.sock not found
错误是 php5-fpm.sock not found
I look at sudo ls -lah /var/run/
我看着 sudo ls -lah /var/run/
there was no php5-fpm.sock
没有 php5-fpm.sock
I edit the www.conf ?
我编辑了 www.conf ?
sudo vim /etc/php5/fpm/pool.d/www.conf
change
改变
listen = 127.0.0.1:9000
for
为了
listen = /var/run/php5-fpm.sock
and reboot
并重新启动