9

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?

4
7

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

1
  • Heres a little explanation of how it works. a2dismod disables php5 from being used as default version by the server and a2enmod sets php7.XX as default php version. Dec 10 '19 at 9:46
3

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à!

4
  • I had to remove the files from the mods-enabled directory for php
    – Beachhouse
    Apr 19 '20 at 20:22
  • There is no folder conf-enabled
    – Black
    Mar 2 at 14:11
  • This solved my problem. In my case, there was /etc/apache2/conf-enabled/php7.1-fpm.conf that prevented me from using PHP 5.6. Even though I disabled PHP 7.1 and enabled PHP 5.6, it was still using PHP 7.1. So, I removed the php7.1-fpm.conf file and now Apache uses PHP 5.6.
    – Barun
    May 31 at 14:28
  • This command will handle the above automatically: sudo a2disconf php5.6-fpm Jul 27 at 9:54
0

Try following one of these:

4
  • My Ubuntu version is 10.04 and the method to add lines in sources.list doesn't work. And i already said that i installed php 5.4 manually. The problem is that Apache doesn't use the 5.4 version but the old version 5.3.2. Jul 21 '15 at 15:11
  • whichever way you installed is incorrect and this is why i'm pointing for you these documents, so you can follow them and get new php to work on your system
    – alexus
    Jul 21 '15 at 15:13
  • Why the manual install should be incorrect? I downloaded php-5.4.0.tar.gz file, then use these commands: tar -xvf php-5.4.0.tar.gz, ./configure, make, make install. I didn't get any errors during the install. Using apt-get doesn't work, it always install php 5.3.2. Jul 21 '15 at 15:29
  • using apt-get is wiser then doing manual install, but if you still want to go ahead with manual install, you should read following php.net/manual/en/install.php
    – alexus
    Jul 21 '15 at 15:30
-1

Php support is added to apache by loading a proper library. If you installed or built this library for your new php version you have to change the apache config files to load the new library instead of the old one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.