Installed new version of php but Apache still using the old version

I manually installed php 5.4 on Ubuntu 10.04. The old version was 5.3.2. Now if i check the php version it shows 5.4:

max@ubuntu:/etc/php5$ php -v
PHP 5.4.0 (cli) (built: Jul 21 2015 14:04:16)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

But if i load index.php file in /var/www/ the apache still shows that the php version is 5.3.2.

How to make apache recognize the new php 5.4 version?


Make sure that you also installed apache module for new version then disable old one and enable new one

Here is example for php5 to php7

sudo a2dismod php5 
sudo a2enmod php7.0

Of course after that restart apache


Same problem here, but a2dismod did not work. I solved it removing the old apache config from /etc/apache2/conf-enabled and adding the right one from conf-available

cd /etc/apache2/conf-enabled
sudo rm php5.6-fpm.conf
sudo ln -s ../conf-available/php7.2-fpm.conf

restart apache et voilà!