【问题标题】:Vagrant: PHP7.0-fpm.service failed because the control process exited with error codeVagrant:PHP7.0-fpm.service 失败,因为控制进程退出并带有错误代码
【发布时间】:2017-06-14 19:42:27
【问题描述】:

我有一个新的基于 ubuntu/xenial64 盒子的 Vagrant 安装。不幸的是,PHP7.0 服务没有运行

如果我运行以下systemctl status php7.0-fpm.service 命令,结果如下:

ubuntu@Project-Yii-Shop:~$ systemctl status php7.0-fpm.service
* php7.0-fpm.service - The PHP 7.0 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.0-fpm.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2017-01-29 14:37:05 UTC; 16min ago
  Process: 2213 ExecStart=/usr/sbin/php-fpm7.0 --nodaemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf (code=exited, s
  Process: 2203 ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf (code=exited, status=0/SUCCESS)
 Main PID: 2213 (code=exited, status=78)

Jan 29 14:37:04 Project-Yii-Shop systemd[1]: Stopped The PHP 7.0 FastCGI Process Manager.
Jan 29 14:37:04 Project-Yii-Shop systemd[1]: Starting The PHP 7.0 FastCGI Process Manager...
Jan 29 14:37:05 Project-Yii-Shop php-fpm7.0[2213]: [29-Jan-2017 14:37:05] ERROR: [pool www] cannot get uid for user 'va
Jan 29 14:37:05 Project-Yii-Shop php-fpm7.0[2213]: [29-Jan-2017 14:37:05] ERROR: FPM initialization failed
Jan 29 14:37:05 Project-Yii-Shop systemd[1]: php7.0-fpm.service: Main process exited, code=exited, status=78/n/a
Jan 29 14:37:05 Project-Yii-Shop systemd[1]: Failed to start The PHP 7.0 FastCGI Process Manager.
Jan 29 14:37:05 Project-Yii-Shop systemd[1]: php7.0-fpm.service: Unit entered failed state.
Jan 29 14:37:05 Project-Yii-Shop systemd[1]: php7.0-fpm.service: Failed with result 'exit-code'.

我尝试启用此服务但 Vagrant Ubuntu 要求输入密码的主要问题是,Vagrant 中的这个 Ubuntu 没有任何密码。我用谷歌搜索了这个问题,但我只看到了这个解决方案和上面的解决方案。

ubuntu@Project-Yii-Shop:~$ systemctl enable php-fpm.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: Ubuntu (ubuntu)
Password: 
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to execute operation: Access denied

所以我不知道我应该怎么做,因为如果我在真正的 Ubuntu 服务器(不是在 Vagrant 中)上安装 PHP7.0,我不会收到此错误。

我使用具有以下配置的 NGINX 服务器:

location ~ \.php$ {
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       #fastcgi_pass   127.0.0.1:9000;
       fastcgi_pass unix:/var/run/php7.0-fpm.sock;
       try_files $uri =404;
   }

我在 Vagrant 文件中使用这个命令来安装 PHP7.0

apt-get install -y git nginx php7.0-curl php7.0-cli php7.0-intl php7.0-mbstring php7.0-gd php-imagick php7.0-fpm php7.0-mysql php7.0-pgsql php7.0-xml php7.0-zip

这个命令在 Vagrant 启动后运行,以便运行 php7.0 服务。

service php7.0-fpm restart

有人看出有什么错误吗?

【问题讨论】:

    标签: nginx vagrant ubuntu-16.04 php-7 ubuntu-server


    【解决方案1】:

    查看您的 php-fpm 池定义 (www.conf ?),它可以在 /etc/php/7.0/fpm/pool.d 中找到。似乎您正试图以用户“vagrant”的身份启动 php-fpm 进程 - 一个似乎不存在于框中的用户。

    通常使用用户www-data 来运行php-fpm:

    user = www-data
    group = www-data
    

    【讨论】:

    • 啊哈,你说得对。我检查了另一个配置文件,而不是这个 www.conf。我应该从 Vagrant 中删除这一行 sed -i 's/user = www-data/user = vagrant/g' /etc/php/7.0/fpm/pool.d/www.conf 吗?因为这设置了用户。
    • 我根本不知道 vagrant,但是从 OS/php-fpm 的角度来看,php-fpm 必须与操作系统上存在的用户一起运行。因此,要么添加该用户,要么将 php-fpm 作为 www-data 运行。
    猜你喜欢
    • 2017-07-20
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 2016-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-22
    相关资源
    最近更新 更多