0

I installed PHP 5.6 and when I run php -v it shows

PHP 5.6.30-7+deb.sury.org~precise+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

but when I get phpinfo(); in index file show in header:

PHP Version 5.3.10-1ubuntu3.26

How can upgrade my php version?

5
  • To what version will you want to upgrade? Apr 8, 2017 at 19:05
  • i want 5.6 version
    – aynaz
    Apr 8, 2017 at 19:24
  • Probably your PHP apache module is still at version 5.3; please edit your question to add the output of dpkg -l | grep libapache2-mod-php.
    – fkraiem
    Apr 9, 2017 at 4:52
  • And please also disregard the current answers; they are probably wrong.
    – fkraiem
    Apr 9, 2017 at 4:55
  • @fkraim that line show: ii libapache2-mod-php5 5.3.10-1ubuntu3.26 server-side, HTML-embedded scripting language (Apache 2 module)
    – aynaz
    Apr 9, 2017 at 19:11

1 Answer 1

0
  1. Open apache config: sudo gedit /etc/apache2/apache2.conf

  2. At the end of the file add the following:
    <IfModule php5_module> PHPIniDir "/etc/php/5.6/apache2/php.ini" </IfModule>

  3. Restart apache: sudo service apache2 restart

UPDATE: if that didn't work, try the following in a terminal:

1. Make sure php 5.3 module is installed:
sudo apt-get install libapache2-mod-php5.6

2. Disable 5.3 and enable 5.6:
sudo a2dismod php5.3 && sudo a2enmod php5.6 && sudo service apache2 restart

With attribution to Grayson Kent, this and this post

5
  • the first solution didn't work and the second solution didn't work too. and show that error :ERROR: Module php7.0 does not exist! ERROR: Module php5.6 does not exist!
    – aynaz
    Apr 9, 2017 at 19:08
  • Please retry the updated second solution
    – lamino
    Apr 9, 2017 at 19:18
  • Generally this answer is on the right track though the exact configuration may vary. The package you need for apache2 is different to the CLI version. For example libapache2-mod-phpVER versus php-VER for the CLI. Other setups are also possible using suphp, fastcgi, etc. Apr 9, 2017 at 19:29
  • @lamino i get this ERROR: Module php5.3 does not exist! ERROR: Module php5.6 does not exist! too!!!
    – aynaz
    Apr 9, 2017 at 19:32
  • Maybe the apache2 module is different or doesn't exist for php5.3. I have no way of knowing that since this version is deprecated. There's also a slight chance purging php5.3* could solve this problem.
    – lamino
    Apr 9, 2017 at 20:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .