claudios claudios - 1 month ago 19
PHP Question

How to update PHP version in homestead

I am having a trouble on updating php version in homestead. When I check the version in

homestead ssh
it says it's php version is
PHP 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1 (cli)
. Now I would like to update the PHP version to 7 for code compatibility. Is there an easy way how to fix this?

I also tried this one from here
but got no luck. Thanks

Answer

You have probably Laravel version 5.0 - https://laravel.com/docs/5.0/homestead, in this version Homestead has Ubuntu 14.04 and PHP 5.6. To update only PHP to 7.0, you need log into the Homestead, and execute:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php7.0-mysql php7.0-fpm php7.0-mbstring php7.0-xml php7.0-curl

Then you need change fastcgi_pass in you configuration files in /etc/nginx/sites-available/* to this fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

and at the end restart services:

/etc/init.d/nginx restart
/etc/init.d/php7.0-fpm restart