0

I need to upgrade the php version to 7.2 in my Lampp. Actually, when I am checking php -v in terminal, it's showing the following result:

PHP 7.2.1-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Jan 11 2018 22:52:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.2.1-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

But I am running the file from opt/lampp/htdocs and there I am getting the php version as 5.6.3 which needs to be upgraded to 7.2. I was referring the following steps to install this originally.

sudo apt-get install apache2 mysql-server php7-mysql php7 libapache2-mod-php7 php7-mcrypt phpmyadmin

Package manager info:

$ apt-cache policy apache2 mysql-server php7-mysql php7 libapache2-mod-php7 php7-mcrypt phpmyadmin
apache2:
  Installed: 2.4.7-1ubuntu4.18
  Candidate: 2.4.7-1ubuntu4.18
  Version table:
     2.4.10-1ubuntu1.1~ubuntu14.04.2 0
        100 http://in.archive.ubuntu.com/ubuntu/ trusty-backports/main amd64 Packages
 *** 2.4.7-1ubuntu4.18 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.4.7-1ubuntu4 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
mysql-server:
  Installed: 5.5.58-0ubuntu0.14.04.1
  Candidate: 5.5.58-0ubuntu0.14.04.1
  Version table:
 *** 5.5.58-0ubuntu0.14.04.1 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     5.5.35+dfsg-1ubuntu1 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
phpmyadmin:
  Installed: 4:4.0.10-1
  Candidate: 4:4.0.10-1
  Version table:
 *** 4:4.0.10-1 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status
N: Unable to locate package php7-mysql
N: Unable to locate package php7
N: Unable to locate package libapache2-mod-php7
N: Unable to locate package php7-mcrypt
David Foerster
  • 36,264
  • 56
  • 94
  • 147
subhra
  • 459
  • @DavidFoerster : Actually I am little bit confused. Can you please share the steps ? – subhra Jan 18 '18 at 12:27
  • @DavidFoerster : I have shared the exact problem I am facing . Let me to explain you again. I upgraded my PHP version to 7.2 when I am checking it via php -v its showing the my correct version. But when I am running one php file from opt/lampp/htdocs by writing the code phpinfo(); its showing that older version which is my issue. Here I need to get that latest version. – subhra Jan 18 '18 at 12:32
  • It appears you have multiple PHP installations and you only upgraded the one that isn't loaded into the web server. I can't tell you how to upgrade a piece of software if I don't know how it was installed originally. – David Foerster Jan 18 '18 at 12:33
  • @DavidFoerster: Then how to resolve this. – satya Jan 18 '18 at 12:50
  • @DavidFoerster : Ok, Let me to provide the steps. 1-sudo apt-get install apache2, 2-sudo apt-get install mysql-server php7-mysql, 3- sudo apt-get install php7 libapache2-mod-php7 php7-mcrypt, 4-sudo apt install phpmyadmin. – subhra Jan 18 '18 at 12:59
  • @DavidFoerster: I have shared the output in my post. – subhra Jan 18 '18 at 13:08
  • If you installed PHP 7 for Apache this way it didn't work since the package manager isn't even aware of such packages. Could you please tell me how you actually installed LAMPP and PHP 7? – David Foerster Jan 18 '18 at 13:13
  • @DavidFoerster : I had LAMPP instalation many days before and one day before I updated the php version like this command sudo apt-get install php7.0. – subhra Jan 18 '18 at 13:17
  • So the package name was php7.0 instead of php7? In that case could you please amend the output of apt-cache to include apt-cache policy php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-mysql? Thanks. – David Foerster Jan 18 '18 at 13:45
  • The output of apt-cache is `apt 1.0.1ubuntu2 for amd64 compiled on Dec 8 2016 16:23:37 Usage: apt-cache [options] command apt-cache [options] showpkg pkg1 [pkg2 ...] apt-cache [options] showsrc pkg1 [pkg2 ...]

    apt-cache is a low-level tool used to query information from APT's binary cache files

    `.

    – subhra Jan 18 '18 at 13:53
  • I run then what is the next. – subhra Jan 18 '18 at 13:55
  • Again, could you please [edit] your post, when you want to add information? Especially file or program output listings (with the help of the {} button in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall it’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks. – David Foerster Jan 18 '18 at 15:19
  • Did you fix this issue ? I am facing almost the same issue. I would like to upgrader my php version from 7.09 -> 7.2 for lampp . – Attila Naghi Feb 10 '18 at 17:15

2 Answers2

0

Seems you have already installed the newest version of PHP, then jump into the 2nd part of this answer. Please check you have installed LAMP stack correctly, follow a tutorial like this,

Then please follow the exact steps.First,

1. Install the newest version of PHP on your Linux machine

# apt update

Then install following packages to install PHP newest PHP versions using PPA,

# apt install python-software-properties

# add-apt-repository ppa:ondrej/php

Then,

# apt update

Then you can check PHP versions available in apt,

$ apt show php -a | grep version or $ apt show php -a | grep -i version

Then install the newest version available in there.For an example, if you want to install PHP version 7.2,

# apt install php7.2

To check if the PHP is in the newest version, run the following command,

$ php -v

2. Change the PHP version of the lamp

# a2dismod php5 to disable current version

# a2enmod php7.2 to enable current version

# service apache2 restart or # /etc/init.d/apache2 restart

Hope you found it useful.

-1

Try this steps and your php version will get upgraded.

apt-get update
sudo apt-get install -y apache2
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip

then check php version,

php-v