Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to bind listening socket for address php-fpm

Tags:

linux

php

nginx

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.

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

Environment: The CentOS 7 with PHP, MariaDB and NginX installed was installed in VirtualBox.

Log/report:

The journalctl shows:

    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]
    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

    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.

like image 920
Kyle Lin Avatar asked Apr 24 '15 23:04

Kyle Lin


2 Answers

Create directory for sock-file:

mkdir -p /var/run/
like image 91
redflasher Avatar answered Oct 11 '22 10:10

redflasher


For fedora, It was missing /run/php-fpm directory. I created the one using mkdir /run/php-fpm

Now start the php-fpm service (I was using it in a docker container)

/usr/sbin/php-fpm
like image 37
Kapil Khandelwal Avatar answered Oct 11 '22 11:10

Kapil Khandelwal