By James Latten
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!
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.