3

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?

  • How did you install PHP 7? – fkraiem Mar 19 '16 at 12:29
  • @fkraiem: using only these two commands sudo apt-add-repository ppa:ondrej/php and sudo apt-get install php7.0 – PHPLover Mar 19 '16 at 12:39
  • Have you installed libapache2-mod-php7.0 as well? If not, maybe your Apache PHP module is still on PHP 5 (you can see it with dpkg -l | grep libapache2-mod-php). – fkraiem Mar 19 '16 at 12:44
  • 1
    sudo apt-get install libapache2-mod-php7.0, what else? – fkraiem Mar 19 '16 at 13:06
  • 1
    @fkraiem:First of all thank you so much for your help. After executing the above command the PHP started working as previously it does. Just a small request from me. Could you please post it in Answer section so that I could accept it as an answer and it would be pretty much helpful to others as well? Thanks once again. – PHPLover Mar 19 '16 at 13:50
2

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.

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.