Ubuntu – How to rebuild/reconfigure the HTTP Apache server after upgrading to PHP 7.0.* on 64-bit Ubuntu 14.04 LTS

Apache2command linePHPserverupgrade

Previously I was using PHP 5.5.32 on my system, everything was working fine. All the PHP programs and projects were running successfully.

Today, I upgraded to PHP 7.0.4 and the trouble starts for me. Not a single 'Hello World' program is running, forget about the entire project.

Now if I type in the URL of a program in address bar to run in a browser(say"http://localhost/hello.php") I'm getting the PHP code as it is displayed in a browser, which was not happening previously when I was using PHP 5.5.32.

If I run the program from the command line(i.e. the terminal) I get the expected output which comes after execution of PHP code. I run the following command from the terminal and got the output.

$ cd /var/www
$ php hello.php

After googling a bit I came to know that Apache is the only issue responsible for this and for resolving it I have to "rebuild Apache" but no where I found how?

Can someone please help me in this regard please by providing me step-by-step detailed answer?

For reference and detailed understanding of the issue I'm facing you can refer the question below link :

Why after PHP upgrade the program runs from command line but displays the PHP code as it is when run in a browser?

Best Answer

  • The php7.0 package does not automatically install the Apache module of PHP 7, which is necessary to execute PHP scripts in Apache. It can be installed from the package libapache2-mod-php7.0.