Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade php to v 7.2 version on ubuntu 16.04

Tags:

php

I want to upgrade my apache php version on ubuntu 16.04. Right now phpinfo() shows 7.0.26. How can I upgrade?

I want to upgrade to phpversion 7.2. sudo apt install php7.2, doesn't update the apache php version. How can I update the apache php version.

like image 425
Ramasamy Viswanathan Avatar asked Dec 13 '22 19:12

Ramasamy Viswanathan


2 Answers

I'm assuming that you already have apache and php 7.0 installed, and that you're using the Ondřej Surý PPA something like this:

LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2

At this point, you would need to remove the old libapache2-mod-php package, install the new one, and restart apache:

sudo apt remove libapache2-mod-php*
sudo apt update
sudo apt install libapache2-mod-php7.2
sudo service apache2 restart

Now, phpinfo() from within a web page should show PHP Version 7.2.0-2+ubuntu16.04.1+deb.sury.org+2

If the add-apt-repository command is missing, you can install it with:

sudo apt install software-properties-common
like image 160
astrangeloop Avatar answered Dec 17 '22 22:12

astrangeloop



Please run below commands to upgrade your PHP version to 7.2

sudo apt-get update
sudo apt-get install python-software-properties
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get install php7.2
sudo a2dismod php7.0
sudo a2enmod php7.2
sudo update-alternatives --set php /usr/bin/php7.2
sudo service apache2 restart
sudo apt-get install libapache2-mod-php7.2 php7.2-cgi php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-imap php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-pspell php7.2-readline php7.2-soap php7.2-xml
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm
sudo service apache2 restart

Hope this helps !!!

like image 41
Danish Shaikh Avatar answered Dec 17 '22 23:12

Danish Shaikh