Report this

What is the reason for this report?

How do i update my LAMP stack to php7?

Posted on December 6, 2015

Hello there i am trying to update my LAMP stack to php7!? I have php5 installed currently.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This is what worked for me:

sudo apt-get install -y language-pack-en-base
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install php7.0
sudo apt-get install php7.0-mysql

For LAMP, you should be able to just update through apt-get:

apt-get install -y language-pack-en-base
apt-get install python-software-properties
dd-apt-repository ppa:ondrej/php-7.0
sudo apt-get update && sudo apt-get dist-upgrade

This is what worked for me.

Upgrading to PHP7 can be done quite smooth. Just use the following commands. First add the new repository for PHP7:

$ apt-get install python-software-properties
$ add-apt-repository ppa:ondrej/php-7.0

Now backup any custom config files since we will remove PHP5 and install PHP7 now:

$ apt-get update && apt-get purge php5-fpm && apt-get --purge autoremove && apt-get install php7.0-fpm php7.0-mysql

At this point, php5-fpm should be removed and the php7.0-fpm service is running. It is, however, unlikely that your website is running properly – because the PHP-FPM socket file will have changed. If you’re running Nginx, you must update your fastcgi_pass directive inside your VHOST from:

fastcgi_pass unix:/run/php/php5.0-fpm.sock;

to:

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

Some Nginx instances runs as the user/group nginx, if thats true in your situation you need to change the php-fpm file:

nano /etc/php/7.0/fpm/pool.d/www.conf

edit

listen.owner = nginx
listen.group = nginx

You might also want to change the user and group at the beginning of the file. If you had www-data in php-5, you can just keep this default. Now restart nginx and php-fpm and it should work properly:"

$ service php7.0-fpm restart
$ service nginx restart

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.