简体   繁体   English

php-fpm 不创建 .sock 文件

[英]php-fpm doesn't create .sock file

I have an AWS server running on Amazon Linux.我有一个在 Amazon Linux 上运行的 AWS 服务器。

I used this guide to install php7 (bottom of the page): https://forums.aws.amazon.com/thread.jspa?messageID=695576我使用本指南安装 php7(页面底部): https ://forums.aws.amazon.com/thread.jspa?messageID=695576

I would like to use nginx instead of Apache, so I've also installed the php70w-fpm and nginx packages.我想使用 nginx 而不是 Apache,所以我还安装了 php70w-fpm 和 nginx 包。 However, when I service start php-fpm , it does not create a php-fpm.sock file anywhere on my server.但是,当我service start php-fpm ,它不会在我的服务器上的任何地方创建 php-fpm.sock 文件。 I have checked in /var/run and have also ran find / -name "*.sock" which only returns /var/run/rpcbind.sock .我已经签入 /var/run 并且还运行了find / -name "*.sock" ,它只返回/var/run/rpcbind.sock

  1. Make sure you have the following folder and that it's writable.确保您有以下文件夹并且它是可写的。 /var/run/php-fpm

  2. then in your www.conf you put: listen = /var/run/php-fpm/php-fpm.sock然后在您的www.conflisten = /var/run/php-fpm/php-fpm.sock

  3. then run: sudo service php-fpm restart然后运行: sudo service php-fpm restart

  4. then update your nginx.conf : fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;然后更新你的nginx.conffastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  5. and finally restart nginx: sudo service nginx restart最后重启 nginx: sudo service nginx restart

Edit: The real solution here is that the listen in www.conf and fastcgi_pass in nginx configuration have to match.编辑:这里真正的解决方案是www.conf中的监听和 nginx 配置中的fastcgi_pass必须匹配。 Whether you use sockets or tcp is up to you.使用套接字还是 tcp 取决于您。

The answer was to not use a .sock file at all.答案是根本不使用.sock文件。

in /etc/php-fpm.d/www.conf it has:/etc/php-fpm.d/www.conf它有:

listen = 127.0.0.1:9000

So in my nginx config I put所以在我的 nginx 配置中,我把

fastcgi_pass 127.0.0.1:9000;

Instead of using something like而不是使用类似的东西

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

I had the same problem - no socket created - and the same solution that Phil had.我遇到了同样的问题 - 没有创建套接字 - 和 Phil 有相同的解决方案。

I had just copy-pasted a pool-file, and only changed the socket-name in the listen-section.我刚刚复制粘贴了一个池文件,并且只更改了侦听部分中的套接字名称。 No socket.没有插座。

This was because the pool name was already in use.这是因为池名称已被使用。 When you already have pool with the same name, then there is not created a new socket.当您已经有同名的池时,则不会创建新的套接字。

So it is important to have a unique pool name for each socket.因此,为每个套接字拥有唯一的池名称非常重要。

So when copy/paste a pool configuration: Change both pool-name and socket-name!因此,当复制/粘贴池配置时:同时更改池名称和套接字名称!

I know its too late, but may be this can help.我知道为时已晚,但这可能会有所帮助。 You can create a new lock file from the scratch using Python.您可以使用 Python 从头开始​​创建一个新的锁定文件。

python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/run/php/php-fpm.sock')"

If your php-fpm is controlled by systemd you have to check PrivateTmp option in your php-fpm service unit file (you can this file this way find /etc/systemd -name "php-fpm*" ! -type d )如果您的 php-fpm 由systemd控制,您必须在您的 php-fpm 服务单元文件中检查PrivateTmp选项(您可以通过这种方式find /etc/systemd -name "php-fpm*" ! -type d该文件find /etc/systemd -name "php-fpm*" ! -type d

If this option is set to true PrivateTmp=true , new file system namespace will be created for php-fpm master process and other process will be unable to manipulate files in this namespace by default (nginx, for example).如果此选项设置为 true PrivateTmp=true ,则将为 php-fpm 主进程创建新的文件系统命名空间,默认情况下其他进程将无法操作此命名空间中的文件(例如 nginx)。 You can read more details about systemd PrivateTmp option here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html您可以在此处阅读有关 systemd PrivateTmp选项的更多详细信息: https : //www.freedesktop.org/software/systemd/man/systemd.exec.html

Hope this helps!希望这可以帮助!

In my case, I missed in /etc/php/7.0/fpm/pool.d/wordpress.conf the correct section就我而言,我在/etc/php/7.0/fpm/pool.d/wordpress.conf错过了正确的部分

[wordpress]
listen = /var/run/php7-fpm-wordpress.sock

The *.sock file is not created from filename but from section name. *.sock 文件不是从文件名创建的,而是从节名创建的。

I had the error, because I copy-pasted a pool.d/xx.conf and the new one had the same pool name [whatever], so the second was not loaded.我遇到了错误,因为我复制粘贴了一个 pool.d/xx.conf 并且新的具有相同的池名称 [whatever],所以没有加载第二个。 No error, no socket.没有错误,没有套接字。

Hope that helps someone :)希望对某人有所帮助:)

In my case when changing PHP version example to PHP7.4 for a specific website in Ispconfig 3.2.2 the webxx.conf file should have been created in /etc/php/7.4/fpm/pool.d/ but instead, it was created at root / .在我的情况下,当在 Ispconfig 3.2.2 中将特定网站的 PHP 版本示例更改为 PHP7.4 时,应该在/etc/php/7.4/fpm/pool.d/创建 webxx.conf 文件,而是创建了它在根/

So for now I just mv the webxx.conf file to /etc/php/7.4/fpm/pool.d/ and restart PHP7.4-fpm sudo systemctl restart php7.4-fpm and it works correctly.所以现在我只是将 webxx.conf 文件 mv 到/etc/php/7.4/fpm/pool.d/并重新启动 PHP7.4-fpm sudo systemctl restart php7.4-fpm并且它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM