[英]Unable to bind listening socket for address php-fpm
I followed the instruction from https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7 , step by step, but while I restarted php-fpm, it failed.我按照https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7的说明一步一步地进行,但是当我重新启动 php-fpm,它失败了。
The error log:错误日志:
Error: unable to bind listening socket for address 'var/run/php-fpm.d/www.conf': no such file or directory Error: FPM initialization failed
错误:无法为地址 'var/run/php-fpm.d/www.conf' 绑定监听套接字:没有这样的文件或目录错误:FPM 初始化失败
Environment: The CentOS 7 with PHP, MariaDB and NginX installed was installed in VirtualBox.环境:VirtualBox中安装了CentOS 7和PHP、MariaDB和NginX。
Log/report:日志/报告:
The journalctl shows: journalctl 显示:
localhost.localdomain php-fpm[2574]: Error: unable to bind listening socket for address '/var/run/php-fpm.d/www.conf' : No such file or directory
localhost.localdomain php-fpm[2574]:Error: FPM initialization failed
localhost.localdomain systemd[1]: php-fpm.service: main process exited, code=exited, status=78/n/a
localhost.localdomain systemd[1]: Failed to start the php fastCGI process manager.
The status shows:状态显示:
php-fpm.service - the php fastcgi process manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled)
Active: failed (result: exit-cod )
Process: 2639 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited,
status=78)
Main PID:2639 (code=exited, status=78)
localhost.localdomain php-fpm[2639]: Error: unable to bind listening socket for address '/var/run/php-fpm.d/www.conf' : No such file or directory
localhost.localdomain php-fpm[2639]: ERROR: FPM initialization failed
localhost.localdomain steam[1]: failed to start the php fastCGI process manager.
localhost.localdomain steam[1]: Unit php-fpm.service entered failed state.
The www.conf is www.conf 是
[www]
listen = /var/run/php-fpm.d/www.conf
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 5
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
Nginx default.conf is Nginx default.conf 是
server{
listen 80;
server_name ip address;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ = 404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~\.php$ {
fastcgi_split_path_info ^(.+?\.php)(./*)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
And, the cgi.fix_pathinfo=0 is checked.并且,检查了 cgi.fix_pathinfo=0。
为 sock 文件创建目录:
mkdir -p /var/run/
For fedora, It was missing /run/php-fpm
directory.对于 Fedora,它缺少
/run/php-fpm
目录。 I created the one using mkdir /run/php-fpm
我使用
mkdir /run/php-fpm
创建了一个
Now start the php-fpm service (I was using it in a docker container)现在启动 php-fpm 服务(我在 docker 容器中使用它)
/usr/sbin/php-fpm
In my case the run
directory was not present in /var/
.在我的情况下,
/var/
不存在run
目录。 So I just create the run
directory inside /var/
所以我只是在
/var/
创建run
目录
mkdir -p /var/run/
and start php-fpm service并启动 php-fpm 服务
sudo service php-fpm start
This working for me.这对我有用。
sudo mkdir -p /var/run/php/
While the mkdir
solves the issue, a more permanent solution would be to edit the unit under systemd so it creates the directory on start.虽然
mkdir
解决了这个问题,但更永久的解决方案是在 systemd 下编辑单元,以便它在启动时创建目录。
In my case for php-fpm on CentOS 7:就我而言,对于 CentOS 7 上的 php-fpm:
systemctl edit --full php72-php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
ExecStartPre=/bin/install -d /var/run/php-fpm -o apache -g apache -m 755
Type=notify
EnvironmentFile=/etc/opt/remi/php72/sysconfig/php-fpm
ExecStart=/opt/remi/php72/root/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.