问题
I have an AWS server running on Amazon Linux.
I used this guide to install php7 (bottom of the page): 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. However, when I service start php-fpm
, it does not create a php-fpm.sock file anywhere on my server. I have checked in /var/run and have also ran find / -name "*.sock"
which only returns /var/run/rpcbind.sock
.
回答1:
Edit: The real solution here is that the listen in www.conf
and fastcgi_pass
in nginx configuration have to match. Whether you use sockets or tcp is up to you.
The answer was to not use a .sock
file at all.
in /etc/php-fpm.d/www.conf
it has:
listen = 127.0.0.1:9000
So in my nginx config I put
fastcgi_pass 127.0.0.1:9000;
Instead of using something like
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
回答2:
I know its too late, but may be this can help. You can create a new lock file from the scratch using Python.
python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/run/php/php-fpm.sock')"
回答3:
In my case, I missed in /etc/php/7.0/fpm/pool.d/wordpress.conf
the correct section
[wordpress]
listen = /var/run/php7-fpm-wordpress.sock
The *.sock file is not created from filename but from section name.
回答4:
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
)
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). You can read more details about systemd PrivateTmp
option here: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
Hope this helps!
回答5:
Make sure you have the following folder and that it's writable.
/var/run/php-fpm
then in your
www.conf
you put:listen = /var/run/php-fpm/php-fpm.sock
then run:
sudo service php-fpm restart
- then update your
nginx.conf
:fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
- and finally restart nginx:
sudo service nginx restart
回答6:
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. No error, no socket.
Hope that helps someone :)
来源:https://stackoverflow.com/questions/35367676/php-fpm-doesnt-create-sock-file