无法为地址 php-fpm 绑定监听套接字

新手上路,请多包涵

我按照 https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7 的说明一步一步地进行操作,但是当我重新启动 php-fpm,它失败了。

错误日志:

错误:无法为地址 ‘var/run/php-fpm.d/www.conf’ 绑定监听套接字:没有这样的文件或目录错误:FPM 初始化失败

环境:VirtualBox安装了CentOS 7,安装了PHP、MariaDB和NginX。

日志/报告:

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.

状态显示:

     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.

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 是

    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;
    }

并且,检查了 cgi.fix_pathinfo=0。

原文由 Kyle Lin 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 693
1 个回答

为 sock 文件创建目录:

 mkdir -p /var/run/

原文由 redflasher 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏