Vagrant | Failed to restart php7.0-fpm.service

Hello all,

I’m not sure if this is the right category for asking this question, but will give it a try.

I’m trying to setup a PHP environment following the instructions given in the book “Jump Start PHP Environment” by Bruno Skvorc.

I downloaded and installed: Vagrant, Virtualbox and Git.

At this point I am in the homestead_improved-master folder, running Git Bash and enter the command “bin/folderfix.sh” followed by “vagrant up” .
It downloaded the box but run into an error at the end:

==> default: Failed to restart php7.0-fpm.service: Unit php7.0-fpm.service not f ound.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

I tried reloading it but the error persists:

$ vagrant reload --provision
==> default: Attempting graceful shutdown of VM…
==> default: Checking if box ‘laravel/homestead’ is up to date…
==> default: Clearing any previously set forwarded ports…
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
_ default: Adapter 1: nat_
_ default: Adapter 2: hostonly_
==> default: Forwarding ports…
_ default: 80 (guest) => 8000 (host) (adapter 1)_
_ default: 443 (guest) => 44300 (host) (adapter 1)_
_ default: 3306 (guest) => 33060 (host) (adapter 1)_
_ default: 5432 (guest) => 54320 (host) (adapter 1)_
_ default: 22 (guest) => 2222 (host) (adapter 1)_
==> default: Running ‘pre-boot’ VM customizations…
==> default: Booting VM…
==> default: Waiting for machine to boot. This may take a few minutes…
_ default: SSH address: 127.0.0.1:2222_
_ default: SSH username: vagrant_
_ default: SSH auth method: private key_
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM…
==> default: Setting hostname…
==> default: Configuring and enabling network interfaces…
==> default: Mounting shared folders…
_ default: /vagrant => C:/Users/mikek/Downloads/MKWP/homestead_improved-master_
_ default: /home/vagrant/Code => C:/Users/mikek/Downloads/MKWP/homestead_impro ved-master_
==> default: Running provisioner: file…
==> default: Running provisioner: shell…
_ default: Running: C:/Users/mikek/AppData/Local/Temp/vagrant-shell20161224-98 04-1trjt88.sh_
==> default: Running provisioner: shell…
_ default: Running: C:/Users/mikek/AppData/Local/Temp/vagrant-shell20161224-98 04-1hiyods.sh_
==> default: Failed to restart php7.0-fpm.service: Unit php7.0-fpm.service not f ound.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Does any of you know how to fix this?

I’m not sure whether it makes a difference to the running of your installation, but the “Downloads” folder is a strange place to install software…

You are right.
I use it as my base folder for all my files.
It’s strange indeed but guess it should be of no influence. :grinning:

I tried installing it in program files but the problem persists.
Any suggestions?

All help is welcome!

And this is the reason why I dislike using 3rd party softwares. Instead of focusing on running your environment, you have to now focus on pleasing the 3rd party software so that it doesn’t break. I’d rather install them manually because this helps you understand which package broke and which didn’t. But you are actually in the right place. If you installed PHP manually (how I prefer it), you would of had a perfectly configured environment. But now you have a 3rd party to worry about. It might be the cause of breaking your environment. Nevertheless, if you are running a Linux partition, you probably won’t be learning anything Linux related because you’ll most likely be using something that is modified only to suit vagrant which I dislike. What’s the fun in running a Linux OS if you aren’t going to be using its commands?

So to properly install the missing piece. In “Linux”, you would do

sudo apt-get -y install php7.0-fpm

The -y flag simply just adds in yes to the installation so that you don’t get prompt questions when installing a package.

Highly doubt it’ll work though since you didn’t install it properly via the “Linux” commands which would of been using the command apt-get add-apt-repository and which would of been a much much much easier installation because you would be relying on NO 3rd party to install your environment.

But this probably won’t help at all. You could try using the Linux command, but I have no clue if it’ll help at all. Best of luck to you.

Thank you for your feedback spaceshiptrooper.
I am really new to this and hoped the book was a good start to a better work environment.
What would you recommend. Do you have a link or book that I shoud read?

I haven’t read the book, but from the sounds of it, it sounds like you need technical skills to have it up and running. I will be doing a written tutorial later today for people new to the whole thing. It’s a much easier way of installing PHP as well. The tutorial I am going to make only expects you to know a few things; how to update packages, how to install packages, and how to remove packages. Other than that, straight forward tutorial with minimum difficulties as we will be installing each individual package. This helps us decide which package needs more work. And if a package breaks, we won’t be relying on a 3rd party software to help fix it for us.

Despite the error message Not Found, I’m thinking it might be a Windows thing.

I’ve had trouble before with running projects under certain folders.

True, Windows does have UIs to configure Group, Permission and Sharing settings.
But I for one still feel uncertain about my understanding them well enough to mess with them very much.

I’ve found it works better when I put my work spaces under my Documents folder.

I have my install in

c:\users\user\homestead_improved-master

which I think from memory was what the book suggests.

1 Like

No. -fpm is only a Linux thing. It wouldn’t matter if your main host is Windows or Linux. Only the current host can effect it. It’s basically the service that starts up PHP. The equivalent to php7.0-fpm on Windows is php.exe. I remember messing around with -fpm once. The first time, I don’t know how I did it, but I broke -fpm. Luckily, it was on the live CD so not much work lost there since I could just restart my PC and try again. I think it had to do with configuring PHP with Apache wrong. The 2nd time, I was trying to uninstall PHP 5 and I uninstalled -fpm thinking I could replace that with PHP 7’s and having another way of upgrading. But I was wrong. Had to reinstall everything all over again.


Edit: @Ethannn I actually started writing the tutorial, but got half way and decided stop. I’ll finish up the tutorial tomorrow and post it on here.

Thanks spaceshiptrooper, I am really looking forward to it!

Sounds like this is a common error, I posted the same here:

am going to try this box:

which is a bit more than what the book uses but i think it was [L,W,M]AMP stack and more. also it seems that it has more contributors that you can reach out to. hope that helps.

Hey, turns out that it might actually take longer. For some odd reason, when you add the repository for PHP 7 to your system and you update your system and try to install PHP 7. It won’t work at all. Keeps saying

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.0
E: Couldn't find any package by regex 'php7.0'

But then when you add the repository to your system, it reads like this.

Co-installable PHP versions: PHP 5.6, PHP 7.0, PHP 7.1 and most requested extensions are included.

PLEASE DON'T USE PHP 5.4 OR PHP 5.5. The PHP 5.5 and later are no longer supported with security updates, therefore they are not included in this repository.

You can get more information about the packages at https://deb.sury.org

BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#business

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it

The installation for PHP on Windows is still the same, so I will be adding just that one into the topic since the one for Ubuntu seems to be broken.

@swader can you provide any help on these topics?

Edit:

The box has been updated and a git pull in the folder should solve your problems. For more info, or if running into problems, please see the stackoverflow answer I linked below.


Gentlemen, I’m very sorry about this - the box was upgraded to 7.1 and the scripts still refer to 7.0, so that’s the whole reason for it.

A quick fix, until I update the box itself, is described here.

5 Likes

I feel really stupid but can’t get it working properly.
I installed the vagrant box in a folder called VM on my C-drive: C:\VM

I created a PHP file called index.php in the “public” folder: C:\VM\Project\public\index.php
Then I updated the Homestead.yaml file as follows

folders:
    - map: c:/VM
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Project/public

The hosts file is updated as follows:

192.168.10.10 homestead.app
192.168.10.10 T1.app

However when I try to view the index.php file in my browser It cannot be found.
Does any of you see what is going wrong?

ps after each try I run the following command to reload.

vagrant reload --provision

I could really use some help with this

What do you get when you point your browser to homestead.app ?

Hello Gandalf.
It returns “This page is unavailable