Search code examples
nginxvagrantubuntu-16.04php-7ubuntu-server

Vagrant: PHP7.0-fpm.service failed because the control process exited with error code


I have a new ubuntu/xenial64 box based Vagrant installation. Unfortunately the PHP7.0 service does not running

If I running the following systemctl status php7.0-fpm.service command this will be the result:

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'.

The main problem that I tried to enable this service but the Vagrant Ubuntu ask for password and well, this Ubuntu in the Vagrant does not have any password. I googled on this problem but I saw this solution only and the above one.

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

So I do not know what I should do, because if I install PHP7.0 on a real Ubuntu server (not in Vagrant) I do not get this error.

I use NGINX server with the following config:

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

I use this command in the Vagrant file to install 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

And this command run after the Vagrant is up in order to run php7.0 srevice.

service php7.0-fpm restart

Does anybody see any mistake?


Solution

  • Look in your php-fpm pool definition (www.conf ?) which is to be found in /etc/php/7.0/fpm/pool.d. Seems you're trying to start the php-fpm process as user "vagrant" - a user that doesn't seem to exist in the box.

    Usually the user www-data is used to run php-fpm:

    user = www-data
    group = www-data