Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Homestead php-7 "php5-fpm: unrecognized service" on vagrant up

Whilst trying to use the php-7 version of Laravel Homestead in a per-project installation, I see this error during vagrant up:

php5-fpm: unrecognized service

I've tried vagrant destroy and reinstalling the Vagrant box, but it still comes back to this error.

I didn't get the error when using Homestead globally.

How might this be fixed?

like image 690
MHG Avatar asked Nov 18 '15 22:11

MHG


2 Answers

The issue was that whilst box: laravel/homestead-7 was set correctly in Homestead.yaml, the composer dependency for laravel/homestead was still using the php-5 version. This meant that the provisioning scripts for Vagrant in vendor/laravel/homestead were those for php-5 and not php-7.

That can be fixed by using a specific branch of laravel/homestead for the composer dependency.

In composer.json, add a custom repository for laravel/homestead:

"repositories": [
    {
        "type": "git",
        "url": "https://github.com/laravel/homestead"
    }
]

And require the php-7 branch specifically for laravel/homestead:

"require-dev": {
    "laravel/homestead": "dev-php-7"
}

Then composer update and re-provisioning the Vagrant box will fix the issue.

UPDATE

laravel/homestead now has PHP 7.0 by default, and the old php-7 branch no longer exists. To resolve this issue, you simply need to update to the latest version of laravel/homestead via composer.json.

like image 159
MHG Avatar answered Sep 16 '22 14:09

MHG


For a quick fix, I found this answer from laracasts very helpful:

cd ~/Homestead && git pull && vagrant destroy && vagrant box update && vagrant up
like image 31
Bluesail20 Avatar answered Sep 17 '22 14:09

Bluesail20