Search code examples
phpnginxvagrantvagrantfilevagrant-provision

Vagrantfile PHP v5.6 specified but v5.5 installed


I have a Vaprobash VagrantFile building a Ubuntu Nginx stack.

In it I specify PHP v5.6:

php_version = "5.6" //Options: 5.5 | 5.6

However, I run

$ vagrant up

when I ssh into the box and do

$ php -v 

it shows PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct 3 2016 13:00:37).

Why wasn't 5.6 installed?


Solution

  • I am not sure this repo has been updated for php after the ppa has been migrated (see https://github.com/oerdnj/deb.sury.org/wiki/PPA-migration-to-ppa:ondrej-php)

    basically in scripts/php.sh you need to replace ppa by

    sudo add-apt-repository ppa:ondrej/php
    

    (make sure to run sudo apt-get update if you're running this command directly from the VM after the initial provisioning) - and to install php5.6 you need to run

    sudo apt-get install -qq libapache2-mod-php5.6
    

    with this change, you now get

    vagrant@vaprobash:~$ php -v
    PHP 5.6.28-1+deb.sury.org~trusty+1 (cli)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
        with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    

    If you need additional php modules, make sure to replace the installation by specifying 5.6 in your php version such as

    sudo apt-get install -qq php5.6-fpm