Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 446
claudios Avatar asked Oct 18 '16 06:10

claudios


People also ask

How do I update Homestead?

Updating Homestead You can find the latest stable release version on Homestead's GitHub releases page. After updating the Vagrant box, you should run the bash init.sh command from the Homestead directory in order to update Homestead's additional configuration files.

How do I update my PHP website?

Log into the control panel of your hosting provider. Under, the “Software” tab, click on Select PHP Version. On the next page, you will see the PHP version your web server is using. Now, click on the current PHP version and then select the latest version from the drop-down.


2 Answers

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
like image 172
Marek Skiba Avatar answered Sep 20 '22 05:09

Marek Skiba


Upgrade the laravel/homestead box itself

$ vagrant box update

ssh into the virtual machine

$ vagrant ssh

and upgrade everything

$ sudo apt-get update
$ sudo apt-get upgrade
like image 37
Yevgeniy Afanasyev Avatar answered Sep 18 '22 05:09

Yevgeniy Afanasyev